lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Charles Patridge" <>
Subject RE: Postal Code Radius Search
Date Wed, 29 Aug 2007 17:01:55 GMT
Here is an example of getting all the zipcodes within a certain radius -

Something I did in SAS but I am sure you can convert the formula into
another language.

Chuck Patridge

Charles Patridge
Full Capture Solutions, Inc.
333 Roberts Street, Suite 400
East Hartford, CT 06108
Phone: 860-291-9517 x 106
-----Original Message-----
From: Steven Rowe [] 
Sent: Wednesday, August 29, 2007 12:37 PM
Subject: Re: Postal Code Radius Search

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

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




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 Rowe
Center for Natural Language Processing

To unsubscribe, e-mail:
For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message