【发布时间】:2014-06-19 12:44:27
【问题描述】:
> db.test.ensureIndex({x: 1, location: '2dsphere'})
{
"createdCollectionAutomatically" : false,
"numIndexesBefore" : 1,
"numIndexesAfter" : 2,
"ok" : 1
}
> db.test.find({x: 0}).explain()
{
"cursor" : "BasicCursor",
"isMultiKey" : false,
"n" : 1,
"nscannedObjects" : 100009,
"nscanned" : 100009,
"nscannedObjectsAllPlans" : 100009,
"nscannedAllPlans" : 100009,
"scanAndOrder" : false,
"indexOnly" : false,
"nYields" : 781,
"nChunkSkips" : 0,
"millis" : 40,
"server" : "hackintosh:27017",
"filterSet" : false
}
MongoDB 版本:2.6.2
我在x和location上创建了一个复合索引,但是当我在x上查询时,为什么它不起作用?
【问题讨论】:
-
您的带有 {x:0} 的文档没有地理空间字段?
-
我怀疑这是一个已知的怪癖,很可能在某个地方有一个 JIRA
-
@kranteg 所有文档都有位置字段。
-
也许SERVER-9257@Sammaye?不过,这应该是在 2.5.4 中修复的
-
@elhoyos 看起来确实如此,所以它现在应该可以工作了
标签: mongodb geospatial mongodb-indexes 2dsphere