lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mitu2009 <>
Subject Correctly indexing latitude and longitude values in Lucene
Date Sun, 28 Jun 2009 17:39:11 GMT


Am working on a  "US based nearest city search within a given radius"
functionality using Lucene API.
Am indexing city's lat and long values in Lucene as follows:

    doc.Add(new Field("latitude", paddedLatitude, Field.Store.YES,
    doc.Add(new Field("longitude", paddedLongitude, Field.Store.YES,

Since Lucene only understands strings and not numbers, am padding lat and
long values.

For example, if original lat and long are 41.811846 and -87.820628
respectively, after padding,values look like:

paddedLatitude -->"0041.811846" and paddedLongitude-->"-087.820628" 

Am doing the same padding while building the nearest city query(using
Lucene's ConstantScoreRangeQuery class).

Given the fact that lat and long values could be decimal/negative numbers,
is this the right approach to index them so that I would get correct nearest
cities in the search results when lucene would perform a number
Range/comparison operation on these values?


View this message in context:
Sent from the Lucene - Java Users mailing list archive at

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

View raw message