0

I want to query solr with distant parameter and the query should be in distance range.

we have all the cities index in solr with their lat long and boundaries now i want to run a query from a lat long , i want all the cities which are after 50 KM range and below 100 KM range.

In short, i want all the cities which are between 50 to 100 KM range from a given lat long.

Uttkarsh Jain
  • 228
  • 1
  • 12

1 Answers1

1

You can use a filter query together with frange and geodist():

&sfield=your_latlon_field&pt=lat,lon&fq={!frange l=50000 u=100000}geodist()
MatsLindh
  • 49,529
  • 4
  • 53
  • 84
  • this is the query we are using to get all the records within 100 km distance. fq={!geofilt pt=-41.2438238,146.41833940000004 sfield=location d=100 sort=geodist(geoBoundary,"41.2438238,146.41833940000004") asc} How do i add frange in it .. i am adding this it but its not working for me – Uttkarsh Jain Dec 03 '19 at 09:23
  • i tried like this however its not working. {!geofilt pt=-41.2438238,146.41833940000004 sfield=location d=100 {!frange l=50 u=100}geodist() }. could you please correct me where i am wrong – Uttkarsh Jain Dec 03 '19 at 09:56
  • You're not using the syntax I wrote and which is used on the linked page - try to start there. Move `sfield` and `pt` out to their own parameters, drop the `d` and `geofilt` completely - the `frange` will do the exclusion. – MatsLindh Dec 03 '19 at 10:11