You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by mitu2009 <mu...@gmail.com> on 2009/06/28 19:39:11 UTC
Correctly indexing latitude and longitude values in Lucene
Hi,
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,
Field.Index.UN_TOKENIZED));
doc.Add(new Field("longitude", paddedLongitude, Field.Store.YES,
Field.Index.UN_TOKENIZED));
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?
Thanks.
--
View this message in context: http://www.nabble.com/Correctly-indexing-latitude-and-longitude-values-in-Lucene-tp24243647p24243647.html
Sent from the Lucene - Java Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org
RE: Correctly indexing latitude and longitude values in Lucene
Posted by mitu2009 <mu...@gmail.com>.
Thanks Uwe...but I have not mentioned the padding logic in my earlier
mail.Just wanted to know if that logic would work.
Uwe Schindler wrote:
>
> I already responded to your eMail and answered all your questions!
>
> -----
> Uwe Schindler
> H.-H.-Meier-Allee 63, D-28213 Bremen
> http://www.thetaphi.de
> eMail: uwe@thetaphi.de
>
>> -----Original Message-----
>> From: mitu2009 [mailto:musicfreaque@gmail.com]
>> Sent: Sunday, June 28, 2009 7:39 PM
>> To: java-user@lucene.apache.org
>> Subject: Correctly indexing latitude and longitude values in Lucene
>>
>>
>> Hi,
>>
>> 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,
>> Field.Index.UN_TOKENIZED));
>>
>> doc.Add(new Field("longitude", paddedLongitude, Field.Store.YES,
>> Field.Index.UN_TOKENIZED));
>>
>> 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?
>>
>> Thanks.
>>
>> --
>> View this message in context: http://www.nabble.com/Correctly-indexing-
>> latitude-and-longitude-values-in-Lucene-tp24243647p24243647.html
>> Sent from the Lucene - Java Users mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
>> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>
>
--
View this message in context: http://www.nabble.com/Correctly-indexing-latitude-and-longitude-values-in-Lucene-tp24243647p24244088.html
Sent from the Lucene - Java Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org
RE: Correctly indexing latitude and longitude values in Lucene
Posted by Uwe Schindler <uw...@thetaphi.de>.
I already responded to your eMail and answered all your questions!
-----
Uwe Schindler
H.-H.-Meier-Allee 63, D-28213 Bremen
http://www.thetaphi.de
eMail: uwe@thetaphi.de
> -----Original Message-----
> From: mitu2009 [mailto:musicfreaque@gmail.com]
> Sent: Sunday, June 28, 2009 7:39 PM
> To: java-user@lucene.apache.org
> Subject: Correctly indexing latitude and longitude values in Lucene
>
>
> Hi,
>
> 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,
> Field.Index.UN_TOKENIZED));
>
> doc.Add(new Field("longitude", paddedLongitude, Field.Store.YES,
> Field.Index.UN_TOKENIZED));
>
> 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?
>
> Thanks.
>
> --
> View this message in context: http://www.nabble.com/Correctly-indexing-
> latitude-and-longitude-values-in-Lucene-tp24243647p24243647.html
> Sent from the Lucene - Java Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org