Correctly indexing latitude and longitude values in Lucene

后端 未结 2 614
名媛妹妹
名媛妹妹 2021-02-10 05:26

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:

<         


        
相关标签:
2条回答
  • 2021-02-10 05:52

    The linked article in Yuval F's answer made me realize I was wrong in an earlier answer, which you seem to be relying on.

    You shouldn't index negative numbers as is, especially in this case, where some of the values are negative and some are positive.

    This article seems to have a pretty good discussion of spatial search. He uses some transformations to make all the values positive, and he also touches on other subjects you should probably be aware of, like distance calculations.

    One thing to remember if you're encoding the values is to encode them both for the indexing and when building the query.

    0 讨论(0)
  • 2021-02-10 06:03

    Here's the bleeding edge about Searching Numerical Fields in Lucene by Uwe Schindler, the expert on the subject. You may need to use the older (and slower) ConstantScoreRangeQuery because Lucene.net is a bit behind Lucene, and the class NumericRangeQuery described in the link was not yet released in Java Lucene.

    0 讨论(0)
提交回复
热议问题