MongoDB使用地理空间索引查询geohash

时间:2019-07-24 07:18:33

标签: mongodb mongodb-geospatial

在ElasticSearch中,它提供了geohash范围搜索功能。

enter image description here

位置是原始位置,但实际上存储在elasticsearch中的数据是geohash(例如wydm6tjq5

因此,假设point集合中有4个文档。

> db.point.find()
{ "_id" : ObjectId("5d37b475d921f8a07089429b"), "name" : "starbucks", "geohash" : "wydm6tjq5" }
{ "_id" : ObjectId("5d37b475d921f8a07089429c"), "name" : "cafebene", "geohash" : "wydm6tk1y" }
{ "_id" : ObjectId("5d37b475d921f8a07089429d"), "name" : "coffebene", "geohash" : "wydm6su1e" }
{ "_id" : ObjectId("5d37b476d921f8a07089429e"), "name" : "burgerking", "geohash" : "wydm6tqtw" }

将每个geohash呈现给纯经纬度,lng和

wydm6tjq5 : 37.513869, 127.031286

wydm6tk1y : 37.514513, 127.029698

wydm6su1e : 37.511723, 127.029569

wydm6tqtw : 37.515156, 127.033131

我想搜索3公里范围内的文档。 (在这种情况下,为wydm6tjq5(starbucks))

可以通过mongodb吗?

我在Google搜索了几个小时,没有关于此的示例。

任何建议,非常感谢。

谢谢。

0 个答案:

没有答案