2016-05-04 4 views
0

SolrJを使用してDB文書を索引付けすると、Solr(5.2.1)に重複文書があることがわかりました。重複を避け、 "id"フィールドに基づいてドキュメントを書き直したい。私のグーグルグーグルでは、 "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"をuniqueKeyまたはunique_idとしてuniqueKeyにしますか? –

+1

SolrJ(Javaコード) –

答えて

0

このURL で見てください

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

定義チェイン(あなたのケースでは「重複排除」)を使用するように更新ハンドラ(あなたがSolrJで使用するもの)を変更してくださいhttps://cwiki.apache.org/confluence/display/solr/De-Duplication

+0

あなたの親切な助けをありがとう。私はあなたのアドバイスで問題を解決することができました。 –

+0

解決策を見つけたことをうれしく思います! –