中的重复文档,我能够发现Solr(5.2.1)中存在重复的文档。我想避免重复,并根据“id”字段重写文档。用我的谷歌搜索,“重复数据删除”对重复是有用的,所以我将它应用到solrconfig.xml中,但遗憾的是它没有工作。使用SolrJ索引DB文档时,避免Solr
if there are two same documents then rewrite with latest one. for example,
"id" = 750000 "title" = here I am
"id" = 750000 "title" = here you are
hence, final result would be "id" =750000 "title" = here you are
//here is my part of schema.xml
<field name="id" type="long" indexed="true" stored="true" required="true"/>
<field name="title" type="string" indexed="true" stored="true" required="true" />
<field name="unique_id" type="string" multiValued="false" indexed="true" required="false" stored="true"
<uniqueKey>unique_id</uniqueKey>
//below code is solrconfig.xml
<updateRequestProcessorChain name="dedupe">
<processor class="solr.processor.SignatureUpdateProcessorFactory">
<bool name="enabled">true</bool>
<str name="signatureField">id</str>
<bool name="overwriteDupes">true</bool>
<str name="fields">id</str>
<str name="signatureClass">solr.processor.TextProfileSignature</str>
</processor>
<processor class="solr.LogUpdateProcessorFactory" />
<processor class="solr.RunUpdateProcessorFactory" />
</updateRequestProcessorChain>
need your kind advice.
below code is core parts of my indexing programe with SolrJ (edited on 2015.05.08)
SolrClient solr = new HttpSolrClient(urlArray[i]); //localhost:8983/solr/#/core_name[i]
String id;
SolrInputDocument doc = new SolrInputDocument();
UpdateResponse response;
String[] array;
for (Map.Entry<String,Object> entry : list.get(i).entrySet()) { // get my DB values such as id, title ,description...
array = String.valueOf(entry.getValue()).split(","); // split DB values depend on ","
id = entry.getKey();
doc.addField("id", entry.getKey()); // unique id
doc.addField("title", array[1]);
doc.addField("link", array[2]);
doc.addField("description", array[3]);
response = solr.add(doc);
doc.clear();
}
solr.commit();
solr.close();
尝试此操作并检查,在模式文件中将此过滤器添加到您的多字段字段类型定义中 –
vinod
要将uniqueKey或unique_id作为uniqueKey ...吗? –
你可以发布索引你的文件在SolrJ(java代码)的代码 –