首页 > 解决方案 > 如何索引具有 geojson 作为 Solr 中的字段的文档?

问题描述

当我尝试索引具有位置类型字段的文档时,它没有结果。我正在尝试索引文档,然后我希望能够在空间上进行搜索。

我正在关注链接,我也使用 SolrCloud 7.5 版,但我无法正确使用 geojson 属性进行空间搜索。

我的 schema.xml

<fieldType name="location" class="solr.LatLonPointSpatialField" docValues="true"/>
...
<field name="id" type="string" multiValued="false" indexed="true" required="true" stored="true"/>
<field name="geo_location" type="location" stored="true"/>
<field name="otherProperty" type="string" stored="true"/>

该文档包含一个 geojson 和任何属性字段

当我尝试使用 rest api 索引此文档时

{
    "id":"12345",
    "location_try": {
        "type": "Feature",
        "geometry": {
            "type": "Point",
            "coordinates": [
                125.6,
                10.1
            ]
        },
        "properties": {
            "name": "Dinagat Islands"
        }
    },
    "otherProperty":"something"
}

http://localhost:8983/solr/geoCollection/update/json/docs?commitWithin=1000&overwrite=true&wt=json&format=geojson

索引操作完成后,托管架构更改为

...
<field name="location_try" type="location" stored="true"/>
<field name="location_try.geometry.coordinates" type="pdoubles"/>
<field name="location_try.geometry.type" type="text_general"/>
<field name="location_try.properties.name" type="text_general"/>
<field name="location_try.type" type="text_general"/>

我可以在集合中看到我的文档,但我无法从查询中获得响应

http://localhost:8983/solr/geoCollection/select?&q=*:*&fq={!geofilt sfield=location_try}&pt=10.11,11.11&d=1

如何正确索引 geojson 并在 solr 中使用空间字段进行搜索?例如,我想在边界框或多边形内获取文档?

标签: solrgeospatialgeojsonsolrcloud

解决方案


推荐阅读