2011-09-13 2 views
11

은 내가 location 필드 (기본값을 사용하여 solr.LatLonType)를 포함하는 SOLR 스키마가 있습니다DataImportHandler를 사용할 때 Solr 위치 (공간) 필드를 채우는 데 사용해야하는 SQL 데이터 유형은 무엇입니까?

<field name="latlng" type="location" indexed="true" stored="true"/> 

을 그리고 나는 DataImportHandler를 사용하여 채우기 위해 노력하고 있어요. 현재 내가 SELECT17.74628,-64.70725의 형식으로 nvarchar 값; 그러나 Solr 필드를 채우지 않습니다 (빈 채로 남아 있음).

Solr의 location 필드를 업데이트하려면이 열을 사용해야하는 유형 및 형식은 무엇입니까?

답변

15

solr.LatLonType은 다차원 유형입니다.

<fieldType name="location" class="solr.LatLonType" subFieldSuffix="_coordinate"/> 

는 "위도와 경도를"당신의 필드 이름을 사용하여 좌표 필드의 스키마 (2 차원 필드 유형 solr.LatLonType에 사용되는 "subFieldSuffix을"알)과 같이 표시됩니다 같이 필드 유형을 정의 할 수 있습니다 :

<field name="latlng" type="location" indexed="true" stored="true" /> 
<field name="latlng_0_coordinate" type="double" indexed="true" stored="true" /> 
<field name="latlng_1_coordinate" type="double" indexed="true" stored="true" /> 

위도와 "latlng_1_coordinate"경도해야한다 "latlng_0_coordinate"이어야합니다. select 문은 "latlng_0_coordinate"및 "latlng_1_coordinate"를 두 배로로드해야합니다.

+0

감사합니다. 나는이 동일한 해결책을 발견하고 그것을 성공적으로 구현했다. – STW

3

위의 답은 Solr이 lat와 long을 개별적으로 저장하는 데 사용하는 필드를 수동으로 생성하기 때문에 작동합니다. 그러나 그 목적을위한 동적 필드가 있습니다.

<!-- Type used to index the lat and lon components for the "location" FieldType --> <dynamicField name="*_coordinate" type="tdouble" indexed="true" stored="false" />

이 필드 유형 위치를 선택하면, 당신이 그 값에 대한 접미사 _coordinate를 사용하여 찾을 수 있습니다 : SOLR 4 베타에서 나를 위해 작동

<!-- A specialized field for geospatial search. If indexed, this fieldType must not be multivalued. -->

<fieldType name="location" class="solr.LatLonType" subFieldSuffix="_coordinate"/>

, 나는 Solr 3.6 이후부터 존재한다고 믿습니다. 어쨌든, 또 다른 해결책!

희망이 도움이됩니다.

관련 문제