[英]how to filter query multivalued location attribute in solr
我试图在我的应用程序中设置Solr Geospatial搜索。 该模型是,我有多个地址的客户,并且我想用每个地址地理代码标记该客户,然后在距中心点一定距离内搜索客户。
只需使用一个地理编码即可。 到目前为止,这是我在架构中针对每个solr条目的多个地理编码的内容:
在Schema.xml中
<fieldType name="location" class="solr.LatLonType" subFieldSuffix="_coordinate"/>
<dynamicField name="*_coordinate" type="tdouble" indexed="true" stored="true"/>
...
<field name="latlng" type="location" indexed="true" stored="true" multiValued="true" />
这很好,尽管当我通过SOLR管理员查询文档时,我只能看到各个坐标字段的值,而不能看到位置的值。 有办法解决这个问题吗?
但是更大的问题是当我执行此SOLR查询时:
http://localhost:8983/solr/aust/select?q=*:*&fq={!geofilt pt=-37.8064822,144.96090520000007 sfield=latlng d=15}&wt=json&indent=true
出现以下错误:
"can not use FieldCache on multivalued field: latlng_0_coordinate"
我认为,这是由于尝试对多值属性执行过滤查询所致。
我在solr管理面板中尝试了此操作:
http://localhost:8983/solr/aust/select?q=*:*&wt=json&indent=true&spatial=true&pt=-27.516473,152.95089480000001&sfield=latlng&d=20
但是它只返回所有文档...
所以我想知道是否还有另一种方法可以查询多值位置参数?
好的,我从一个重复的问题中得到了答案: 在带有多值位置字段的solr中搜索
因此,我将在此答案中包括的有趣部分是,我使用DIH长时间导入了lat。 因此,您可以使用以空格分隔的字段直接导入字段:
select ..., concat(concat(lng, ' '),lat)... from ...
从外观上看,此新类型为SOLR 4类型,并支持对多值属性的过滤器查询。
所以我的架构现在看起来像这样:
<fieldType name="location_rpt" class="solr.SpatialRecursivePrefixTreeFieldType"
distErrPct="0.025"
maxDistErr="0.000009"
units="degrees" />
<field name="location" type="location_rpt" indexed="true" stored="true" multiValued="true" />
然后,来自SOLR 4的过滤器查询将按预期工作。
很高兴这个问题得以解决,这对我的应用来说是一个巨大的胜利,也是至关重要的一环!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.