2013-07-23 2 views
11

다음과 같이 나는 필드 SOLR에 LocationIndex라는 인덱스가 있습니다SOLR 복합 고유 키

<fields> 
    <field name="solr_id" type="string" stored="true" required="true" indexed="true"/> 
    <field name="solr_ver" type="string" stored="true" required="true" indexed="true" default="0000"/> 
    // and some more fields 
</fields> 
<uniqueKey>solr_id</uniqueKey> 

하지만 지금은 고유 키가이 이미 존재하는 복합 있어야합니다 수 있도록 스키마를 변경하려면 필드 solr_idsolr_ver ... 뭔가를 다음과 같이

<fields> 
    <field name="solr_id" type="string" stored="true" required="true" indexed="true"/> 
    <field name="solr_ver" type="string" stored="true" required="true" indexed="true" default="0000"/> 
    <field name="composite-id" type="string" stored="true" required="true" indexed="true"/> 
    // and some more fields 
</fields> 
<uniqueKey>solr_ver-solr_id</uniqueKey> 

을 내가 스키마에 다음을 추가하여 가능 발견 검색 한 후 : (참조 : Solr Composite Unique key from existing fields in schema)

<updateRequestProcessorChain name="composite-id"> 
    <processor class="solr.CloneFieldUpdateProcessorFactory"> 
    <str name="source">docid_s</str> 
    <str name="source">userid_s</str> 
    <str name="dest">id</str> 
    </processor> 
    <processor class="solr.ConcatFieldUpdateProcessorFactory"> 
    <str name="fieldName">id</str> 
    <str name="delimiter">--</str> 
    </processor> 
    <processor class="solr.LogUpdateProcessorFactory" /> 
    <processor class="solr.RunUpdateProcessorFactory" /> 
</updateRequestProcessorChain> 

그래서 내가 스키마를 변경하고 마침내는 다음과 같습니다

<updateRequestProcessorChain name="composite-id"> 
    <processor class="solr.CloneFieldUpdateProcessorFactory"> 
    <str name="source">solr_ver</str> 
    <str name="source">solr_id</str> 
    <str name="dest">id</str> 
    </processor> 
    <processor class="solr.ConcatFieldUpdateProcessorFactory"> 
    <str name="fieldName">id</str> 
    <str name="delimiter">-</str> 
    </processor> 
    <processor class="solr.LogUpdateProcessorFactory" /> 
    <processor class="solr.RunUpdateProcessorFactory" /> 
</updateRequestProcessorChain> 

<fields> 
    <field name="solr_id" type="string" stored="true" required="true" indexed="true"/> 
    <field name="solr_ver" type="string" stored="true" required="true" indexed="true" default="0000"/> 
    <field name="id" type="string" stored="true" required="true" indexed="true"/> 
    // and some more fields 
</fields> 
<uniqueKey>id</uniqueKey> 

그러나 문서를 추가하는 동안 그것은 나에게 오류주고 :

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 

을 I는 스키마에 어떤 변화받지 못했습니다 원하는대로 일해야합니까?

문서에 추가 할 내용은 solr_versolr_id입니다. 어떻게 그리고 어디에서 (solr) solr_ver-solr_id과 같은 두 가지 필드를 결합하여 id 필드를 만들까요?

편집 :이 체인을 참조하는 방법을 주어진 것

this link에서. 부 스키마에서 어떻게 사용되는지 이해할 수 없습니까? 그리고 나는 어디에서 변경해야합니까?

+0

당신이 당신의 DB-data.config 파일을 게시 할 수 있습니다 – Nipun

답변

10

updateRequestProcessorChain이 적절하게 정의되어있는 것처럼 보이므로 작동해야합니다. 그러나이 값을 schema.xml이 아닌 solrconfig.xml 파일에 추가해야합니다. 추가 링크는 solrconfig.xml 파일을 수정하고 정의 된 updateRequestProcessorChain을 solr 인스턴스의 현재 /update 요청 처리기에 추가하는 방법을 보여줍니다.

그래서 다음과 같이 찾을 :

    <updateRequestProcessorChain>로 solrconfig.xml 파일을 이동
  1. . 이처럼 보이는, 그래서
  2. 업데이트합니다 solrconfig.xml 파일의 <requestHandler name="/update" class="solr.UpdateRequestHandler"> 입력 및 수정 다음

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

이 그러면 정의 업데이트 체인을 실행할 때 새 문서 id 필드를 채워야 색인에 추가됩니다.

+0

나는 당신이 말했던 것처럼 업데이트했고, rect ..하지만 지금은'CloneFieldUpdateProcessorFactory'에 대한 클래스를 찾을 수 없습니다 오류가 발생했습니다. 오래된 solr 버전에서는이 기능을 사용할 수 없습니까? 나는 'Solr Specification Version : 3.4.0.2011.09.09.09.06.17','Solr Implementation Version : 3.4.0 1167142 - mike - 2011-09-09 09 : 06 : 17'의 사양을 가진 solr을 사용하고 있습니다. –

+0

방금 ​​Solr 소스를 살펴 봤지만 불행히도'CloneFieldUpdateProcessorFactory'는 Solr 4.x 버전에서만 사용 가능하며 Solr 3.x 버전에는 포함되어 있지 않습니다. 죄송합니다. –

+0

나는이 오류가 발생했습니다 문서에 필수 uniqueKey 필드가 누락되었습니다 : composite-id. 문서에서이 composite-id를 정의해야합니까? – Nipun

4

위의 해결 방법에는 연결된 필드가 너무 길기 때문에 "dest"가 최대 길이를 초과하면 몇 가지 제한이있을 수 있습니다. MD5Signature 하나 개 이상의 대안 또한 여기에서

<!-- 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> 

(지정된 문서 필드 그룹의 연결로부터 서명 스트링을 생성 할 수있는 클래스는 128 비트 해시 정확한 중복 검출을 위해 사용) http://lucene.472066.n3.nabble.com/Solr-duplicates-detection-td506230.html

여기에 더 나은 링크는, 어쨌든 ...
+0

이 솔루션을 사용해도 여전히 나에게 제공됩니다. 문서에 필수 uniqueKey "id"가 없습니다. – Nipun