2012-06-22 2 views
7

나는 LatLng 필드를 가진 문서를 가지고 있습니다. LatLng에서 가져온 데이터가 포함 된 store이라는 새 필드를 추가해야합니다. 나는 copyField 필드를 사용하려고 노력하지만 오류 가지고 :Solr에서 2 개의 필드 데이터를 하나의 필드에 복사하는 방법

<fields> 
    <field name="lat" type="sdouble" indexed="true" stored="true" required="true" multiValued="false" /> 
    <field name="lng" type="sdouble" indexed="true" stored="true" required="true" multiValued="false" /> 
    <field name="store" type="text" indexed="true" stored="true"/> 
</fields> 

<copyField source="lat" dest="store"/> 
<copyField source="lng" dest="store"/> 

는 동일한 대상 필드 내에서 두 필드의 내용을 복사 할 수 있습니다 : 여기

Field store is not multivalued and destination for multiple copyFields (2)

을 내 구성은?

+0

를 사용할 수 있습니다. – Mirodil

답변

2

당신은 컨텍스트없이 질문을 복용 store

<field name="store" type="location" indexed="true" stored="true" multiValued="true" /> 
+0

'store' 필드를 multiValued로 만들면됩니다. 색인 생성에 오류가 발생했습니다. – Mirodil

+1

사실, 실제로는 다른 두 필드의 연결로 채워진 단일 값 필드가 필요합니다. 그 맞습니까? –

+0

네, 맞습니다. – Mirodil

6

multivalued로 설정을 시도 할 수 있습니다 :

Is it possible to copy the content of two fields within the same destination field?"

대답은 확실히 '예'입니다. 예제 스키마는 하나의 필드를 더 간단하게 검색하기 위해 여러 필드를 공통 "텍스트"필드 (multiValued)로 복사하는 작업을 수행합니다.

더 많은 컨텍스트를 살펴보면 copyField를 사용하는 Solr의 schema.xml이 입력 필드 쌍 (예 : 위도와 경도)을 가져 와서 중간 쉼표로 연결하여 특정 분야. 내 대답은 아니오 야. Solr에게 줄 때 데이터를 이런 방식으로 준비해야하며, DIH (DataImportHandler)를 사용하는 경우 DIH 변환기를 사용해야합니다. 대안을 제시하는 것을 주저하지만 해킹으로 lat와 lon을 store_0_coordinate 및 store_1_coordinate (또는 다른 방법 일 수 있습니다)에 넣는 것이 좋습니다. 그러나 실제로 이것은 작동 할 수 있다고해도 권장 된 방법이 아닙니다.

+0

"UpdateRequestProcessor"로이 작업을 수행 할 수 있습니까? – Mirodil

+0

URP를 작성할 수 있습니다. URP를 사용하는 것이 좋습니다. –

+0

감사합니다. * .csv 파일에서 데이터를로드 중이며 * .csv 파일에 3 열의 우편 번호, 위도, 경도가 있습니다. 구성 URP를 도와 주시겠습니까? – Mirodil

0

당신은 그런 식으로 뭔가를 시도 할 수 있습니다 :

Two double in one location

당신은 다이 하이드로 (데이터 가져 오기 처리기)를 사용 할 수 있습니다. 희망 thet 도움이 될 것입니다!

4

는 어쩌면 시대에 뒤 떨어진 것이하지만 당신은 내가이 문제가 해결되지 않는 볼 경우 당신은 "updateRequestProcessorChain"

<updateRequestProcessorChain name="composite-position"> 
    <processor class="solr.CloneFieldUpdateProcessorFactory"> 
    <str name="source">lat</str> 
    <str name="source">lng</str> 
    <str name="dest">store</str> 
    </processor> 
    <processor class="solr.ConcatFieldUpdateProcessorFactory"> 
    <str name="fieldName">store</str> 
    <str name="delimiter">;</str> 
    </processor> 
    <processor class="solr.LogUpdateProcessorFactory" /> 
    <processor class="solr.RunUpdateProcessorFactory" /> 
</updateRequestProcessorChain> 
관련 문제