Solr Composite来自模式中现有字段的唯一键

我在solr中有一个名为LocationIndex的索引,其字段如下:

    // and some more fields  solr_id 

但是现在我想要更改模式,以便唯一键必须是两个已经存在的字段solr_idsolr_ver ……如下所示:

     // and some more fields  solr_ver-solr_id 

搜索之后我发现可以通过在schema中添加以下内容:(ref: Solr Composite来自模式中现有字段的唯一键 )

   docid_s userid_s id   id --     

所以我改变了架构,最后它看起来像:

   solr_ver solr_id id   id -         // and some more fields  id 

但是在添加文档时它会给我错误:

 org.apache.solr.client.solrj.SolrServerException: Server at http://localhost:8983/solr/LocationIndex returned non ok status:400, message:Document [null] missing required field: id 

我没有得到模式的哪些变化需要按预期工作?

在我添加的文档中,它包含字段solr_versolr_id 。 如何以及在何处(solr)通过将这些字段组合为solr_ver-solr_id创建id字段?

编辑:

在这个链接给出了如何引用这个链。 我无法理解如何在架构中使用它? 我应该在哪里进行更改?

因此,看起来您已正确定义了updateRequestProcessorChain,它应该可以正常工作。 但是,您需要将其添加到solrconfig.xml文件而不是schema.xml。 您提供的附加链接向您显示如何修改solrconfig.xml文件,并将定义的updateRequestProcessorChain添加到solr实例的当前/update请求处理程序中。

所以找到以下内容:

  1. 移动到solrconfig.xml文件。
  2. 更新solrconfig.xml文件中的条目并对其进行修改,使其如下所示:

       composite-id   

然后,这应该执行您定义的更新链,并在将新文档添加到索引时填充id字段。

上述解决方案可能具有一些限制,如果“dest”超过最大长度,因为连接字段太长。 MD5Signature还有一个解决方案(一个类能够从一组指定文档字段的串联生成签名字符串,128位散列用于精确重复检测)

    true false id name,features,cat org.apache.solr.update.processor.Lookup3Signature     

从这里: http : //lucene.472066.n3.nabble.com/Solr-duplicates-detection-td506230.html

我想把它添加为评论,但这些天不可能获得信誉……无论如何,这是一个更好的链接: https : //wiki.apache.org/solr/Deduplication