Faceting on distance in solr- how to generate link

2019-07-04 02:10发布

问题:

It is fairly simple to generate facets for ranges or 'buckets' of distance in Solr: http://wiki.apache.org/solr/SpatialSearch#How_to_facet_by_distance

What isnt described is how to generate the links for these facets

If this is the query to return everything within 5km :

&q=:&fq={!geofilt sfield=store}&pt=45.15,-93.85&d=5

-what then would be the syntax to search for everything between 5 and 10km ?

Basically I can generate distance facets, but I dont know how to generate the links for the distance facets:

for example, what would the links for the following facets look like?:

distance

0-1km (2)

1-5km (0)

5-20km (0)

20-50km (0)

50-100km (0)

100-250km (0)

回答1:

The wiki does describe it:

&q=*:*&sfield=store&pt=45.15,-93.85&facet.query={!frange l=0 u=5}geodist()&facet.query={!frange l=5.001 u=3000}geodist()

This will generate a facet from 0 to 5km and another from 5km to 3000km. Change the values in frange according to your needs.

If you meant filtering with a range of distances, moving the facet query to a filter query should work, e.g. fq={!frange l=5.001 u=3000}geodist()