MongoDB:复合地理空间和;升序索引问题

MongoDB:复合地理空间和;升序索引问题,mongodb,geospatial,mongodb-.net-driver,Mongodb,Geospatial,Mongodb .net Driver,我有一个由简单的升序索引和地理空间索引组成的计算索引: { v: 1, key: { PlayerSortMask: 1, RandomGeoIdentifier: "2dsphere" }, ns: "JellyDev.Players", name: "Sort Mask + Random Geo ID", min: 0, max: 1 } 现在我有以下两个问题: 一,。 当我尝试使用前缀索引(仅查询第一个索引)时,使用的是一个基本游标,而不是我创建的索引: 使用的查询: { "Player

我有一个由简单的升序索引和地理空间索引组成的计算索引:

{ v: 1, key: { PlayerSortMask: 1, RandomGeoIdentifier: "2dsphere" }, ns: "JellyDev.Players", name: "Sort Mask + Random Geo ID", min: 0, max: 1 }
现在我有以下两个问题:

一,。 当我尝试使用前缀索引(仅查询第一个索引)时,使用的是一个基本游标,而不是我创建的索引:

使用的查询:

{ "PlayerSortMask" : 2 }
返回的解释:

{ "cursor" : "BasicCursor", "isMultiKey" : false, "n" : 1, "nscannedObjects" : 1, "nscanned" : 1, "nscannedObjectsAllPlans" : 1, "nscannedAllPlans" : 1, "scanAndOrder" : false, "indexOnly" : false, "nYields" : 0, "nChunkSkips" : 0, "millis" : 0, "indexBounds" : { }, "allPlans" : [{ "cursor" : "BasicCursor", "n" : 1, "nscannedObjects" : 1, "nscanned" : 1, "indexBounds" : { } }], "server" : "widmore:10010" }
二,。 不确定这是否是一个问题,但当我使用$eq和$near两个字段进行查询时,我得到以下解释:

{ "cursor" : "S2NearCursor", "isMultiKey" : true, "n" : 1, "nscannedObjects" : 1, "nscanned" : 6, "nscannedObjectsAllPlans" : 1, "nscannedAllPlans" : 6, "scanAndOrder" : false, "indexOnly" : false, "nYields" : 0, "nChunkSkips" : 0, "millis" : 0, "indexBounds" : { }, "nscanned" : NumberLong(6), "matchTested" : NumberLong(1), "geoMatchTested" : NumberLong(1), "numShells" : NumberLong(3), "keyGeoSkip" : NumberLong(5), "returnSkip" : NumberLong(0), "btreeDups" : NumberLong(0), "inAnnulusTested" : NumberLong(1), "allPlans" : [{ "cursor" : "S2NearCursor", "n" : 1, "nscannedObjects" : 1, "nscanned" : 6, "indexBounds" : { } }], "server" : "widmore:10010" }
这是用于获取结果的查询:

{ "PlayerSortMask" : 2, "RandomGeoIdentifier" : { "$near" : { "$geometry" : { "type" : "Point", "coordinates" : [0.88434365572610107, 0.90583264916475525] } } } }
现在它说它使用了
S2NearCursor
,但它显然不是我创建的索引,因为它的名称是
排序掩码+随机地理ID


任何帮助都将不胜感激。

对于问题1,MongoDB中存在一个已知的问题,即复合地理索引。 这个问题在2.5.4中得到了修复,它是一个beta版本

您现在可以通过在PlayerSortMask上创建一个附加的简单索引来解决这个问题

对于问题2,S2NearCursor表示正在使用索引。我认为解释“丢失”了名称,这是一个已知的问题,但我记不起错误号