NoSQL:如何检索基于lat&长? [英] NoSQL: How to retrieve a 'house' based on lat & long?

查看:105
本文介绍了NoSQL:如何检索基于lat&长?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用于存储房地产房屋的NoSQL系统。

I have a NoSQL system for storing real estate houses.

我在每个房子的键值存储中有一个信息是经度纬度

One piece of information I have in my key-value store for each house is the longitude and latitude.

如果我要检索地理纬度/长框,像下面的SQL:

If I wanted to retrieve all houses within a geo-lat/long box, like the SQL below:

SELECT * from houses 
WHERE latitude IS BETWEEN xxx AND yyy
AND longitude IS BETWEEN www AND zzz

问题:


  1. 我如何使用NoSQL ...只使用键值存储系统进行这种类型的检索?

  1. How would I do this type of retrieval with NoSQL ... using just a key-value store system?

即使我能用NoSQL做到这一点,它会更有效率,或者只是回到使用传统数据库更快地检索这种类型的信息?

Even if I could do this with NoSQL, would it even be efficient or would simply going back to using a tradition database retrieve this type of information faster?


推荐答案

MongoDB是我知道的唯一支持地理空间索引的NoSQL数据库。如果您使用的是MongoDB,您应该查看文档,但基本上您将创建一个地理空间索引:

MongoDB is the only NoSQL database I know of that supports geospatial indexes. If you're using MongoDB, you should look at the documentation, but basically you'd create a geospatial index with:

db.houses.ensureIndex({house : "2d"})

您可以插入点:

db.houses.insert({house : {latitude : y, longitude : x}})


b $ b

然后使用以下命令查询它:

and then query for it with:

db.houses.find({house : {$within : {$box : [[xxx, yyy], [www, zzz]]}}})

MongoDB还允许您在给定的半径范围内搜索,并且只为最接近的点匹配。

MongoDB also lets you search within a given radius and just for the nearest matches to a point.

这篇关于NoSQL:如何检索基于lat&长?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆