无法对Solr地理空间搜索结果进行排序

5
我们如何让Solr 3.6.1返回地理空间搜索结果,既可以通过bbox进行过滤,又可以按距离排序?
我尝试在URL末尾附加一个&sort=geodist() asc,如Solr文档所述,但是却收到了以下错误信息: sort参数无法解析为查询条件,并且不是索引中存在的字段:geodist() 带有排序和bbox的查询URL(未能正常工作):
http://localhost8080/solr/select?wt=json&indent=true
&q=*:*
&fl=id,latlng
&fq={!bbox%20pt=42.352455,-71.048069%20sfield=latlng%20d=5}
&sort=geodist() asc

带排序的查询URL(有效)

http://localhost:8080/solr/select?wt=json&indent=true
&fl=id,latlng
&q=*:*
&sfield=latlng
&pt=42.352455,-71.048069
&sort=geodist()%20asc

使用bbox查询URL(有效)

http://localhost8080/solr/select?wt=json&indent=true
&q=*:*
&fl=id,latlng
&fq={!bbox%20pt=42.352455,-71.048069%20sfield=latlng%20d=5}

我如何同时使用bbox过滤和按距离(geodist())排序结果?
1个回答

5
只需将您拥有的“pt”和“sfield”本地参数提取到顶级查询参数中,就像您在工作排序查询中所做的那样。 您的fq将仅为{!bbox d=5}。

为什么必须将 ptsfield 参数拿出来,但是在花括号中留下 d 参数的原因是什么? - Nyxynyx
所谓的“查询解析器”(如bbox)首先在其本地参数中查找参数,然后回退到顶级URL参数。它们需要位于顶层,以便geodist()可以看到它们。 - David Smiley

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接