Solr Composite Unique key from existing fields in schema

大兔子大兔子 提交于 2019-11-27 21:30:19

So it looks like you have your updateRequestProcessorChain defined appropriately and it should work. However, you need to add this to the solrconfig.xml file and not the schema.xml. The additional link you provided shows you how to modify your solrconfig.xml file and add your defined updateRequestProcessorChain to the current /update request handler for your solr instance.

So find do the following:

  1. Move your <updateRequestProcessorChain> to your solrconfig.xml file.
  2. Update the <requestHandler name="/update" class="solr.UpdateRequestHandler"> entry in your solrconfig.xml file and modify it so it looks like the following:

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

This should then execute your defined update chain and populate the id field when new documents are added to the index.

The described above solution may have some limitations, what if "dest" is over maximum length because concatenated fields are too long. There is also one more solution with MD5Signature (A class capable of generating a signature String from the concatenation of a group of specified document fields, 128 bit hash used for exact duplicate detection)

<!-- An example dedup update processor that creates the "id" field on the fly 
     based on the hash code of some other fields.  This example has 
     overwriteDupes set to false since we are using the id field as the 
     signatureField and Solr will maintain uniqueness based on that anyway. --> 
<updateRequestProcessorChain name="dedupe"> 
  <processor class="org.apache.solr.update.processor.SignatureUpdateProcessorFactory"> 
    <bool name="enabled">true</bool> 
    <bool name="overwriteDupes">false</bool> 
    <str name="signatureField">id</str> 
    <str name="fields">name,features,cat</str> 
    <str name="signatureClass">org.apache.solr.update.processor.Lookup3Signature</str> 
  </processor> 
  <processor class="solr.LogUpdateProcessorFactory" /> 
  <processor class="solr.RunUpdateProcessorFactory" /> 
</updateRequestProcessorChain> 

From here: http://lucene.472066.n3.nabble.com/Solr-duplicates-detection-td506230.html

I'd like to add this as a comment, but it's impossible to get the creds these days... anyway, here is a better link: https://wiki.apache.org/solr/Deduplication

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