1
votes

I am using spatial in solr and generating a dist:geodist() paramater on the fly. How can I group results by ranges of distance i.e.

?group.query=dist[0 To 3]&group.query[3 TO 5]

If I try the above query it tells me there is no "dist" field. If I try with geodist() it tells me it can't parse it.

1
What do you mean by "generating a dist:geodist() paramater on the fly" ? How do you generate it ?EricLavault

1 Answers

0
votes

You can use function range queries : ...&group.query={!frange l=0 u=3}geodist()....

You should use incl=false or incu=false in the parameters to prevent having duplicates in the resulting groups (something equivalent to ranges [0 To 3] and ]3 TO 5], or [0 To 3[ and [3 TO 5]).

A query would look like :

q=*:*&spatial=true&pt=0.0,0.0&sfield=geofield&group=true&group.query={!frange l=0 u=3}geodist()&group.query={!frange l=3 u=5 incl=false}geodist()

You can also use geodist() as a group function like : group.func=geodist(geofield,0.0,0.0) but it would make it more difficult to control the granularity (ranges) this way.