lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Steven Rowe <sar...@syr.edu>
Subject Re: Postal Code Radius Search
Date Wed, 29 Aug 2007 16:37:24 GMT
Mike wrote:
> I've searched the mailing list archives, the web, read the FAQ, etc and I
> don't see anything relevant so here it goes…
> 
> I'm trying to implement a radius based searching based on zip/postal codes.

Here is a selection of interesting threads from the Lucene ML with
relevant info:

<http://www.nabble.com/all-records-within-distance----small-index-tf3303731.html>

<http://www.nabble.com/Hacking-proximity-search%3A-looking-for-feedback-tf1201416.html>

<http://www.nabble.com/Announcement%3A-Lucene-powering-Monster-job-search-index-%28Beta%29-tf2522646.html>

The standard answer seems to be something like:

1. Index latitude and longitude fields with fixed length
(left-zero-padded) integral values - shift the decimal point to the
right to the desired level of discriminability.  (In your case, convert
the postal codes to lats/longs.)

2. Do a range query on both your lat and your long fields to collect
hits inside a bounding box with your target at the center and with sides
of length double the desired radius.

3. Optionally, sort (and filter) the results by distance from your
target, displaying only those within the desired radius.  If you leave
out this step, you'll get some hits that are outside of the desired
radius - inbetween the bounding circle and the bounding box.

Steve

-- 
Steve Rowe
Center for Natural Language Processing
http://www.cnlp.org/tech/lucene.asp

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Mime
View raw message