1
這是一個來自mongo文檔的視圖。我只想保留鍵值最長的文檔中的條目。這裏的關鍵值是一個字符串,因此,與最長的字符串長度的密鑰應該只停留過濾器mongo文檔 - python
{
"_id" : ObjectId("585a431415c7a981b47ac4ee"),
"key" : "http://www.adnansami.com",
"value" : "A"
}
{
"_id" : ObjectId("585a431415c7a981b47ac4ef"),
"key" : "http://www.leap-networks.com",
"value" : "BB"
}
{
"_id" : ObjectId("585a431d15c7a981b47ac4f0"),
"key" : "http://www.leap-networks.com",
"value" : "B"
}
{
"_id" : ObjectId("585a431d15c7a981b47ac4f1"),
"key" : "http://www.machinelearningmastery.com",
"value" : "C"
}
{
"_id" : ObjectId("585a432515c7a981b47ac4f2"),
"key" : "http://www.leap-networks.com",
"value" : "BBB"
}
{
"_id" : ObjectId("585a432815c7a981b47ac4f3"),
"key" : "http://www.machinelearningmastery.com",
"value" : "CC"
}
{
"_id" : ObjectId("585a432d15c7a981b47ac4f4"),
"key" : "http://www.leap-networks.com",
"value" : "BBBB"
}
{
"_id" : ObjectId("585a433115c7a981b47ac4f5"),
"key" : "http://www.machinelearningmastery.com",
"value" : "CCC"
}
{
"_id" : ObjectId("585a433615c7a981b47ac4f6"),
"key" : "http://www.leap-networks.com",
"value" : "BBBBB"
}
{
"_id" : ObjectId("585a433d15c7a981b47ac4f7"),
"key" : "http://www.machinelearningmastery.com",
"value" : "CCCC"
}
{
"_id" : ObjectId("585a434915c7a981b47ac4f8"),
"key" : "http://www.machinelearningmastery.com",
"value" : "CCCCC"
}
所以輸出應該是
{
"_id" : ObjectId("58539dc715c7a964817686f9"),
"http://www.adnansami.com" : "A "
}
{
"_id" : ObjectId("585a433615c7a981b47ac4f6"),
"key" : "http://www.leap-networks.com",
"value" : "BBBBB"
}
{
"_id" : ObjectId("585a434915c7a981b47ac4f8"),
"key" : "http://www.machinelearningmastery.com",
"value" : "CCCCC"
}
我怎樣才能做到這一點?
我越來越錯誤'字符名稱中的點符號需要在第3行col 1'引號,嘗試編輯,但不工作 – Guru
我已編輯th我在文件中提出了有關變更的問題。有了這個更改文檔,我只是從查詢中刪除了「收視率」。對不起,延遲迴應 – Guru
我對查詢做了同樣的改變,即:「去除評分」仍然無效? – Guru