[英]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.