使用DataImportHandler时,应使用什么SQL数据类型来填充Solr位置(空间)字段?

STW*_*STW 11 solr geospatial dataimporthandler

我有一个Solr架构,其中包含一个location字段(使用默认值solr.LatLonType):

<field name="latlng" type="location" indexed="true" stored="true"/>
Run Code Online (Sandbox Code Playgroud)

我试图使用DataImportHandler填充它.目前我SELECT的值为nvarchar,格式为17.74628,-64.70725; 但它没有填充Solr字段(它仍然是空的).

此列中应该使用什么类型和格式来更新locationSolr中的字段?

小智 15

solr.LatLonType是一个多维类型; 您可以将字段类型定义为:

<fieldType name="location" class="solr.LatLonType" subFieldSuffix="_coordinate"/>
Run Code Online (Sandbox Code Playgroud)

使用您的字段名称"latlng",坐标字段的模式将如下所示(请注意用于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" />
Run Code Online (Sandbox Code Playgroud)

"latlng_0_coordinate"应该是纬度,"latlng_1_coordinate"应该是经度.您的select语句应加载"latlng_0_coordinate"和"latlng_1_coordinate"作为双精度.