The easiest modification is to use: calc_square_of_distance(CLIENT_LAT, CLIENT_LONG, lat, long) < maxSquareOfTravelDist
This has the same ordering as before, but is much cheaper to calculate. You can then calculate the actual distance in the GUI, where you're only showing a handful of values. cheers stuart ________________________________________ From: Development Team [dev.and...@gmail.com] Sent: Saturday, 11 July 2009 8:01 a.m. To: solr-user@lucene.apache.org Subject: How to do a "reverse distance" search? Hi everybody, Let's say we have 10,000 traveling sales-people spread throughout the country. Each of them has has their own territory, and most of the territories overlap (eg. 100 sales-people in a particular city alone). Each of them also has a maximum distance they can travel. Some can travel country-wide, others don't have a car and are limited to a 10mi radius. Given that we have a client at a particular location, how do we construct a query in Solr that finds all the sales-people who can reach that client? We think we have a solution for this, but I want to know what you think. And, in SQL this is relatively easy: "select * from salespeople where calc_distance(CLIENT_LAT, CLIENT_LONG, lat, long) < maxTravelDist" But a problem is that calc_distance() is fairly expensive. If it was our "client" that specified the distance, it would be easy to include it as part of the search criteria in the Solr query, but unfortunately it's each individual sales-person that specifies a distance. Sincerely, Daryl.