【发布时间】:2016-06-21 11:24:11
【问题描述】:
我尝试使用{explain:true} 获取有关我在 MongoDB 3.2.5 上所做的聚合的信息,以查看是否使用了我的索引:
db.mycollection.aggregate([{
"$geoNear": {
"near": {
type: "Point",
coordinates: [2.48043, 49.14128]
},
"spherical": true,
"distanceField": "distance",
"maxDistance": 500
}
}, {
"$match": {
"date": {
$gt: new ISODate("2016-01-01T01:01:01Z")
}
}
}, {
"$sort": {
"score": -1,
"distance": 1
}
}], {
explain: true
});
结果我只得到了阶段聚合:
{
"waitedMS": NumberLong(0),
"stages": [{
"$geoNear": {
"near": {
"type": "Point",
"coordinates": [
2.48043,
49.14128
]
},
"distanceField": "distance",
"limit": NumberLong(100),
"maxDistance": 500,
"query": {
},
"spherical": true,
"distanceMultiplier": 1
}
}, {
"$match": {
"date": {
"$gt": ISODate("2016-01-01T01:01:01Z")
}
}
}, {
"$sort": {
"sortKey": {
"score": -1,
"distance": 1
}
}
}],
"ok": 1
}
我没有关于扫描的文档、使用的索引等的任何信息...
有人可以帮帮我吗?
【问题讨论】:
标签: mongodb aggregation-framework mongodb-indexes