Hi Aman, That’s an interesting feature request that I haven’t heard before.
First reaction: Helliosearch (a fork of Solr that is kept up to date with changes from Solr) is extremely close to supporting such a thing because it supports sorting facets by Helliosearch specific aggregation functions. http://heliosearch.org/solr-facet-functions/ However, none of its aggregation functions are spatial oriented. If this feature is important enough to you, you could very well add it. It would likely involve encoding the coordinate into the place name to avoid unnecessary redundant calculations that would be needed if another field were used. Second reaction: You could do a secondary search just for these facet values that works using Result Grouping (AKA Field Collapsing). Add to each document the coordinates of the city indexed using a LatLonType field. On this request, sort the documents using geodist(), and group on the city name. Perhaps you can even get away with returning no documents per group if Solr lets you — you don’t need the doc data after all. The main thing I don’t like about this approach is that it’s going to internally calculate the distance very redundantly since all documents for a city are going to have the coordinate. Well see if it’s fast enough and give it a try. ~ David Smiley Freelance Apache Lucene/Solr Search Consultant/Developer http://www.linkedin.com/in/davidwsmiley On Mon, May 26, 2014 at 8:31 AM, Aman Tandon <amantandon...@gmail.com>wrote: > Hi, > > Is it possible to sort the results return on faceting by geo spatial > distance instead of result count. > > Currently i am faceting on city, which returns me the top facets on behalf > of the docs matched for that particular city. > > e.g.: > Delhi,400 > Noida, 380 > . > . > . > etc. > > If the user selects the city then the facets should be according to the geo > spatial distance instead of results, Is it possible with the solr 4.7.x.? > > With Regards > Aman Tandon >