2016-06-21 38 views
1

解釋我試圖讓上我總有關MongoDB 3.2.5做的,以利用{explain:true}查看信息如果使用我的指標:的MongoDB:嘗試獲得對聚集

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 
} 

我沒有對文檔進行掃描,使用索引等任何信息......

有人可以幫助我,好嗎?

回答

0

按照手冊

操作返回的光標與包含 關於聚合 流水線的處理的詳細信息的文件。例如,該文件可能會顯示 其中的哪些索引(如果有)使用的操作。

所以有一種模棱兩可的,但可能如果換成$geoNear$match - 解釋應該表現出更多的東西。

+0

如果我遵循手冊,$ geoNear必須是合成管道中的第一個階段......不是? –

+0

好@CedricLecocq這可能是爲什麼索引不包括在解釋條目(和事件,他們無法使用) – profesor79

+0

我試圖交換$ geoNear和$匹配,但我得到了一個錯誤,因爲我的預期... 如果我刪除了$ geoNear舞臺,在我正在尋找的信息類型的解釋中,我獲得了一個$ cursor遊標階段... –