geoHaystack
IndexesOn this page本页内容
MongoDB 5.0 removes the deprecated geoHaystack index and MongoDB 5.0删除了不推荐使用的geoSearch
command. geoHaystack
索引和geoSearch命令。Use a 2d index with 改为使用带有$geoNear
or one of the supported geospatial query operators instead.$geoNear
的2d索引或支持的地理空间查询运算符之一。
Upgrading your MongoDB instance to 5.0 and setting featureCompatibilityVersion to 将MongoDB实例升级到5.0并将5.0
will delete any pre-existing geoHaystack indexes.featureCompatibilityVersion
设置为5.0
将删除任何预先存在的geoHaystack
索引。
A geoHaystack
index is a special index that is optimized to return results over small areas. geoHaystack
索引是一种特殊的索引,可以优化以返回小区域的结果。geoHaystack
indexes improve performance on queries that use flat geometry.geoHaystack
索引提高了使用平面几何体的查询的性能。
For queries that use spherical geometry, a 2dsphere index is a better option than a haystack index. 对于使用球面几何体的查询,2dsphere索引比haystack索引更好。2dsphere indexes allow field reordering; geoHaystack
indexes require the first field to be the location field. 2dsphere
索引允许字段重新排序;geoHaystack
索引要求第一个字段是位置字段。Also, 此外,geoHaystack
indexes are only usable via commands and so always return all results at once.geoHaystack
索引只能通过命令使用,因此总是一次返回所有结果。
geoHaystack
indexes create "buckets" of documents from the same geographic area in order to improve performance for queries limited to that area. 索引创建来自同一地理区域的文档“bucket”,以提高仅限于该区域的查询的性能。Each bucket in a geoHaystack
index contains all the documents within a specified proximity to a given longitude and latitude.geoHaystack
索引中的每个bucket都包含给定经度和纬度指定范围内的所有文档。
sparse
默认情况下,geoHaystack
indexes are sparse by default and ignore the sparse: true option. geoHaystack
索引是稀疏的,并忽略sparse:true
选项。If a document lacks a 如果文档缺少geoHaystack
index field (or the field is null
or an empty array), MongoDB does not add an entry for the document to the geoHaystack
index. geoHaystack
索引字段(或该字段为null
或空数组),MongoDB不会将该文档的条目添加到geoHaysack
索引中。For inserts, MongoDB inserts the document but does not add to the 对于插入,MongoDB会插入文档,但不会添加到geoHaystack
index.geoHaystack
索引中。
geoHaystack
indexes include one 索引包括一个geoHaystack
index key and one non-geospatial index key; however, only the geoHaystack
index field determines whether the index references a document.geoHaystack
索引键和一个非地理空间索引键;但是,只有geoHaystack
索引字段确定索引是否引用文档。
geoHaystack
indexes only support simple binary comparison and do not support the collation.索引只支持简单的二进制比较,不支持排序规则。
To create a 要在具有非简单排序规则的集合上创建geoHaystack
index on a collection that has a non-simple collation, you must explicitly specify {collation: {locale: "simple"} }
when creating the index.geoHaystack
索引,必须在创建索引时显式指定{collation: {locale: "simple"} }
。
geoHaystack
IndexgeoHaystack
索引To create a 要创建geoHaystack
index, see Create a Haystack Index. geoHaystack
索引,请参阅创建干草堆索引。For information and example on querying a haystack index, see Query a Haystack Index.有关查询干草堆索引的信息和示例,请参阅查询干草垛索引。