RE: Sort by distance from location?

2009-04-21 Thread Ensdorf Ken
I've never used them personally, but I think a function query would suit you 
here.  Function queries allow you to define a custom function as a component of 
the score of a result document.  Define a distance function based on the user's 
current location and the that of the search result, such that the shorter the 
distance, the higher the function output.  This will boost results inversely 
proportional to the distance from the user.

-Ken

 -Original Message-
 From: Development Team [mailto:dev.and...@gmail.com]
 Sent: Tuesday, April 14, 2009 5:32 PM
 To: solr-user@lucene.apache.org
 Subject: Sort by distance from location?

 Hi everybody,
  My index has latitude/longitude values for locations. I am
 required to
 do a search based on a set of criteria, and order the results based on
 how
 far the lat/long location is to the current user's location. Currently
 we
 are emulating such a search by adding criteria of ever-widening
 bounding
 boxes, and the more of those boxes match the document, the higher the
 score
 and thus the closer ones appear at the start of the results. The query
 looks
 something like this (newlines between each search term):

 +criteraOne:1
 +criteriaTwo:true
 +latitude:[-90.0 TO 90.0] +longitude:[-180.0 TO 180.0]
 (latitude:[40.52 TO 40.81] longitude:[-74.17 TO -73.79])
 (latitude:[40.30 TO 41.02] longitude:[-74.45 TO -73.51])
 (latitude:[39.94 TO 41.38] longitude:[-74.93 TO -73.03])
 [[...etc...about 10 times...]]

  Naturally this is quite slow (query is approximately 6x slower
 than
 normal), and... I can't help but feel that there's a more elegant way
 of
 sorting by distance.
  Does anybody know how to do this or have any suggestions?

 Sincerely,

  Daryl.


Sort by distance from location?

2009-04-14 Thread Development Team
Hi everybody,
 My index has latitude/longitude values for locations. I am required to
do a search based on a set of criteria, and order the results based on how
far the lat/long location is to the current user's location. Currently we
are emulating such a search by adding criteria of ever-widening bounding
boxes, and the more of those boxes match the document, the higher the score
and thus the closer ones appear at the start of the results. The query looks
something like this (newlines between each search term):

+criteraOne:1
+criteriaTwo:true
+latitude:[-90.0 TO 90.0] +longitude:[-180.0 TO 180.0]
(latitude:[40.52 TO 40.81] longitude:[-74.17 TO -73.79])
(latitude:[40.30 TO 41.02] longitude:[-74.45 TO -73.51])
(latitude:[39.94 TO 41.38] longitude:[-74.93 TO -73.03])
[[...etc...about 10 times...]]

 Naturally this is quite slow (query is approximately 6x slower than
normal), and... I can't help but feel that there's a more elegant way of
sorting by distance.
 Does anybody know how to do this or have any suggestions?

Sincerely,

 Daryl.


Re: Sort by distance from location?

2009-04-14 Thread Smiley, David W.
Have you tried LocalSolr?
http://www.gissearch.com/localsolr
(I haven't but looks cool)


On 4/14/09 5:31 PM, Development Team dev.and...@gmail.com wrote:

Hi everybody,
 My index has latitude/longitude values for locations. I am required to
do a search based on a set of criteria, and order the results based on how
far the lat/long location is to the current user's location. Currently we
are emulating such a search by adding criteria of ever-widening bounding
boxes, and the more of those boxes match the document, the higher the score
and thus the closer ones appear at the start of the results. The query looks
something like this (newlines between each search term):

+criteraOne:1
+criteriaTwo:true
+latitude:[-90.0 TO 90.0] +longitude:[-180.0 TO 180.0]
(latitude:[40.52 TO 40.81] longitude:[-74.17 TO -73.79])
(latitude:[40.30 TO 41.02] longitude:[-74.45 TO -73.51])
(latitude:[39.94 TO 41.38] longitude:[-74.93 TO -73.03])
[[...etc...about 10 times...]]

 Naturally this is quite slow (query is approximately 6x slower than
normal), and... I can't help but feel that there's a more elegant way of
sorting by distance.
 Does anybody know how to do this or have any suggestions?

Sincerely,

 Daryl.



Re: Sort by distance from location?

2009-04-14 Thread Development Team
Ah, good question:  Yes, we've tried it... and it was slower. To give some
avg times:
Regular non-distance Searches: 100ms
Our expanding-criteria solution:  600ms
LocalSolr:  800ms

(We also had problems with LocalSolr in that the results didn't seem to be
cached in Solr upon doing a search. So each page of results meant another
800ms.)

- Daryl.


On Tue, Apr 14, 2009 at 5:34 PM, Smiley, David W. dsmi...@mitre.org wrote:

  Have you tried LocalSolr?
 http://www.gissearch.com/localsolr
 (I haven’t but looks cool)