Missing mandatory unique key field error in SolrJ

后端 未结 1 1821
悲哀的现实
悲哀的现实 2021-01-26 04:05

I\'ve this issue in my project. I read my .xlsx excel file using Apache Poi and I want to index them in my Solr core. I use SolrInputDocument to index reading file. Here is my j

相关标签:
1条回答
  • 2021-01-26 04:21

    You probably have in your schema a field set as the unique key like this:

    <uniqueKey>id</uniqueKey>
    

    The problem is that when you upload a doc, in this case via Apache POI, you are not sending a value for that unique field.

    You have a couple options:

    1. If you do have a field that will be unique, use it. For example, with a copyField option like:
    <copyField source="excel_guaranteed_unique" dest="id"/>
    
    1. As you have the actual document, you could just add a UUID to the "id" field.

    2. Create a unique field like a UUID updating your RequestHandlder, like this:

    <updateRequestProcessorChain name="uuid" >
        <processor class="solr.UUIDUpdateProcessorFactory">
          <str name="fieldName">id</str>
        </processor>
        ...
    </updateRequestProcessorChain>
    ...    
    <requestHandler name="/update" class="solr.UpdateRequestHandler">
        <lst name="defaults">
            <str name="update.chain">uuid</str>
        </lst>
    </requestHandler>
    

    You also need to update the extract handler:

     <requestHandler name="/update/extract"
                  startup="lazy"
                  class="solr.extraction.ExtractingRequestHandler" >
    <lst name="defaults">
      ...
      <str name="update.chain">uuid</str>
    </lst>
    

    0 讨论(0)
提交回复
热议问题