MongoDB如何实现其空间索引? [英] How does MongoDB implement it's spatial indexes?

查看:190
本文介绍了MongoDB如何实现其空间索引?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当前实现将地理哈希码编码为最高标准 MongoDB B树. $ near查询的结果是准确的.一个限制 有了这种编码,虽然速度很快,但前缀查找没有给出 准确的结果,尤其是在翻转位区域附近. MongoDB解决了这个问题 通过在初始前缀扫描后进行网格邻居搜索来选择 上升任何散乱的点.这通常可以确保性能 在提供正确结果的同时保持很高的水平.

The current implementation encodes geographic hash codes atop standard MongoDB B-trees. Results of $near queries are exact. One limitation with this encoding, while fast, is that prefix lookups don't give exact results, especially around bit flip areas. MongoDB solves this by doing a grid-neighbor search after the initial prefix scan to pick up any straggler points. This generally ensures that performance remains very high while providing correct results.

这是否意味着mongodb将地球分成几个网格?

Does that mean mongodb split the earth into several grids?

推荐答案

Greg Studer(10gen)的本次演讲详细讨论了地理空间索引: 使用MongoDB进行地理空间索引.

This presentation from Greg Studer (10gen) discusses the geospatial indexes in some detail: Geospatial Indexing with MongoDB.

MongoDB 2.2上的标准地理空间实现使用2-D GeoHash 方法,该方法具有可变性精度:

The standard geospatial implementation as at MongoDB 2.2 uses a 2-D GeoHash approach, with variable bits of precision:

By default, precision is set to 26 bits which is equivalent to approximately
2 feet given (longitude, latitude) location values and default (-180, 180)
bounds.

GeoHash方法确实存在边缘情况,其中某些点在空间上可能接近,但具有不同的哈希值. MongoDB还包括一个地理空间干草堆索引,该索引专门针对小型区域进行了调整

The GeoHash approach does have edge cases where some points may be spatially close but have different hashes. MongoDB also includes a Geospatial Haystack Index which is specifically tuned for small-region "near" long/lat searches with one additional indexed criteria (for example: "find all restaurants within 25 miles with name 'foo'").

Nicholas Knize(Thermopylae)的另一个有趣的演讲将当前的B树/GeoHash方法与 R -树.如果您跳过幻灯片8,则有一个直观的说明可能会有所帮助: 使用MongoDB进行RTree空间索引-MongoDC .

Another interesting presentation from Nicholas Knize (Thermopylae) contrasts the current B-tree / GeoHash approach with R-trees. If you skip ahead to slide 8, there is a visual explanation that may be helpful: RTree Spatial Indexing with MongoDB - MongoDC.

这篇关于MongoDB如何实现其空间索引?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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