如何在solr 7.6中为地理空间搜索配置schema.xml?
我使用Solr7.6进行搜索和过滤。我想使用Solr Spatial Search筛选位置附近的数据,但找不到任何数据 我在schema.xml中做了以下更改:如何在solr 7.6中为地理空间搜索配置schema.xml?,solr,geospatial,Solr,Geospatial,我使用Solr7.6进行搜索和过滤。我想使用Solr Spatial Search筛选位置附近的数据,但找不到任何数据 我在schema.xml中做了以下更改: <fieldType name="location" class="solr.LatLonPointSpatialField" docValues="true" /> <field name="latlong" type="location" indexed="true" stored="true"/> 我的答
<fieldType name="location" class="solr.LatLonPointSpatialField" docValues="true" />
<field name="latlong" type="location" indexed="true" stored="true"/>
我的答复是:
{
"responseHeader":{
"status":0,
"QTime":0,
"params":{
"q":"*:*",
"d":"5",
"pt":"22.303894, 70.802162",
"fq":"{!geofilt sfield=latlong}",
"_":"1556533385742"}},
"response":{"numFound":0,"start":0,"docs":[]
}}
预期文件:
{
"zipCode":"360001",
"currencySign":"₹",
"suspendedByAdmin":false,
"likeCount":62,
"id":1372,
"longitude":70.8023621,
"countryname":"India",
"statename":"Gujarat",
"suspended":false,
"city":"Rajkot",
"latitude":22.2913494,
"description":"Description is here"
"_version_":1632151597023756288},
终于找到了解决办法。
首先将latlong值作为文本(lat,long)
然后将该latlong值指定为位置,这将用作地理空间查询的sfield
<fieldType name="location" class="solr.LatLonPointSpatialField" docValues="true" />
<field name="latlong" type="text_general" indexed="true" stored="false" multiValued="false"/>
<field name="location" type="location" indexed="true" stored="true" multiValued="false"/>
答复:
{
"responseHeader":{
"status":0,
"QTime":1,
"params":{
"q":"*:*",
"d":"5",
"pt":"22.303894,70.802162",
"fq":"{!geofilt sfield=store}",
"_":"1557114448320"}},
"response":{"numFound":15,"start":0,"docs":[
{
"zipCode":"360003",
"currencySign":"₹",
"suspendedByAdmin":false,
"likeCount":45,
"id":509,
"longitude":70.8147741,
"latlong":"22.3024966,70.8147741",
"_version_":1632752689826758656,
"store":"22.3024966,70.8147741},
{...
您是否看到并将您的字段配置为
LatLonPointSpatialField
?是的,我尝试过,但不起作用那么“不起作用”是什么意思?如果您返回文档,内容是否存在?您是否为geofilt使用了正确的语法?({!geofilt sfield=store}
-{!
和}
部分很重要)。架构浏览器是否显示您在schema.xml
中定义的字段和类型?-是的,我使用的语法正确。-是架构浏览器显示我的字段和schema.xml中定义的类型。-我已将我的字段配置为“LatLonPointSpatialField”,现在是否需要进行更多更改?您仍然缺少希望找到的示例文档。
<copyField source="latlong" dest="location"/>
d=5&fq={!geofilt sfield=location}&pt=22.303894,70.802162&q=*:*
{
"responseHeader":{
"status":0,
"QTime":1,
"params":{
"q":"*:*",
"d":"5",
"pt":"22.303894,70.802162",
"fq":"{!geofilt sfield=store}",
"_":"1557114448320"}},
"response":{"numFound":15,"start":0,"docs":[
{
"zipCode":"360003",
"currencySign":"₹",
"suspendedByAdmin":false,
"likeCount":45,
"id":509,
"longitude":70.8147741,
"latlong":"22.3024966,70.8147741",
"_version_":1632752689826758656,
"store":"22.3024966,70.8147741},
{...