0

I want to use UUIDUpdateProcessorFactory to automatically generate UUID as the uniqueKey field for all new documents that will be created. I followed the given instructions & also tried already given solutions here & here but nothing worked. I am using solr version 9.1.1 on Ubuntu 22.04.1 LTS.
I amgetting the error: missing required field: id.
Following is my current configuration which is generating error:

solr-spec: 9.1.1
lucene-spec: 9.3.0

managed-schema.xml
-----------------------
<fieldType name="uuid" class="solr.UUIDField" indexed="true"/>
<field name="id" type="uuid" indexed="true" stored="true" required="true" multiValued="false" />
<field name="_root_" type="uuid" indexed="true" stored="false" docValues="false" />
<uniqueKey>id</uniqueKey>


solrconfig.xml
---------------
<updateRequestProcessorChain name="uuid">
    <processor class="solr.UUIDUpdateProcessorFactory">
      <str name="fieldName">id</str>
    </processor>
    <processor class="solr.RunUpdateProcessorFactory" />
</updateRequestProcessorChain>

 <requestHandler name="/update" class="solr.UpdateRequestHandler">
       <lst name="defaults">
         <str name="update.chain">uuid</str>
       </lst>
</requestHandler>

Error Message:

RequestHandlerBase   org.apache.solr.common.SolrException: [doc=null] missing required field: id

Please advise what I am missing?

Sagar Patel
  • 4,993
  • 1
  • 8
  • 19
MyO
  • 413
  • 1
  • 8
  • 19
  • How are you invoking the `uuid` update processor chain? – MatsLindh Feb 06 '23 at 11:45
  • @MatsLindh I have only configured as mentioned above. I am new to solr & assumed other all background work is automatically done by solr. New documents creation request is sent using PHP SolrClient. Kindly share any relevant link for the guidance. – MyO Feb 06 '23 at 12:18
  • No update processor chains are applied unless asked for, you can explicitly tell Solr to run the `uuid` chain by appending `?update.chain=uuid` to the URL when the request is performed, or you can add it to the configuration to always have it be applied by Solr, either through `initParams` (schemaless) or `requestHandler`: https://solr.apache.org/guide/solr/latest/configuration-guide/update-request-processors.html#configuring-a-custom-chain-as-a-default – MatsLindh Feb 06 '23 at 13:37
  • @MatsLindh ```requestHandler``` is already in use as mentioned above in my question but its not working: ``` uuid ``` – MyO Feb 06 '23 at 17:05
  • @MatsLindh Do we need to send empty ```id``` field or it will be automatically added by solr? Surprisingly if I send request without any ```id``` field I get error but if I send following request with empty ```id```, solr successfully creates new document with uuid: ```$product = new SolrInputDocument(); $product->addField('id', ''); $product->addField('category', 'shirt');``` Is it the right way to use uuid for id field? – MyO Feb 07 '23 at 04:40
  • I've never used the processor, so I can't say. I'd, just as you, expect the field to be added if missing so that it was always present. – MatsLindh Feb 07 '23 at 09:00

0 Answers0