solrdatastax-search

Solr: Query based on distance field


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.


Solution

  • 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()