Correctly indexing latitude and longitude values in Lucene

后端 未结 2 1076
太阳男子
太阳男子 2021-02-10 05:31

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:44

    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.

提交回复
热议问题