Missing mandatory unique key field error in SolrJ

冷暖自知 提交于 2019-12-02 07:50:35

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>

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!