我正在使用转换为JSON的OSM文件。在此查询中,我正在尝试获取.json文件中所有设施的计数。我需要知道如何使输出反转。
查询: -
db.char.aggregate([{"$match":{"amenity":{"$exists":1}}}, {"$group":{"_id":"$amenity",
"count":{"$sum":1}}}, {"$sort":{"count":1}}, {"$limit":100}])
电流输出: -
{ "_id" : "bar", "count" : 1 }
{ "_id" : "fitness_center", "count" : 1 }
{ "_id" : "fountain", "count" : 1 }
{ "_id" : "studio", "count" : 1 }
{ "_id" : "telephone", "count" : 1 }
{ "_id" : "nightclub", "count" : 1 }
{ "_id" : "shelter", "count" : 1 }
{ "_id" : "courthouse", "count" : 1 }
{ "_id" : "kindergarten", "count" : 1 }
{ "_id" : "doctors", "count" : 1 }
{ "_id" : "laboratory", "count" : 1 }
{ "_id" : "toilets", "count" : 2 }
{ "_id" : "community_centre", "count" : 2 }
{ "_id" : "embassy", "count" : 2 }
{ "_id" : "fire_station", "count" : 2 }
{ "_id" : "townhall", "count" : 2 }
{ "_id" : "prison", "count" : 2 }
{ "_id" : "clinic", "count" : 2 }
{ "_id" : "pub", "count" : 3 }
{ "_id" : "grave_yard", "count" : 3 }
答案 0 :(得分:1)
<强> { “$排序”:{ “计数”: - 1}} 强>
在排序部分应该做到你!