Proximity Search

前端 未结 3 1207
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-07 15:22

How does an application perform a proximity search? For example, a user types in a postal code, then the application lists all the businesses within 20 miles ordered by prox

3条回答
  •  感动是毒
    2020-12-07 15:46

    If there are enough records for speed to matter, here's a way to index them ahead of time.

    Define a grid of bins about 20 miles on a side. Store the bin number with each store's record. At search time, compute the numbers of all bins that intersect a 20-mile radius from your search point. Then retrieve all stores in any of those bins, and proceed as before.

提交回复
热议问题