2016-05-04 2 views
0

при индексировании документов DB с использованием SolrJ, я смог найти дублированные документы в Solr (5.2.1). Я хочу избежать дублирования и переписать документы на основе поля «id». с моим googling, «dedupe» полезен для дублирования, поэтому я применил его к solrconfig.xml, но, к сожалению, это не сработало.избегать дублированных документов в 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(); 
+0

Попробуйте это и проверьте. В файле схемы добавьте этот фильтр в определение многозначного типа поля. vinod

+0

Вы хотите, чтобы «id» был уникальнымKey или unique_id как uniqueKey ...? –

+1

Можете ли вы опубликовать код, который вы индексируете свои документы в SolrJ (код Java) –

ответ

0

убедитесь, чтобы изменить обработчики обновления (те, которые вы используете в SolrJ), чтобы использовать определенную цепь (в вашем случае «дедупликации»)

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

Посмотрите на эту ссылку https://cwiki.apache.org/confluence/display/solr/De-Duplication

+0

Благодарим вас за помощь. Я смог решить проблему с вашими советами. –

+0

Я рад, что вы нашли решение! –

Смежные вопросы