在MongoDB中创建$ Near组

时间:2017-08-01 08:10:19

标签: mongodb mongodb-query

我有一个集合,其中包含一组将在地图上打印的地理点。 我想将附近的所有点组合30米,并返回所有点但分组。

我如何进行此查询? 谢谢!

我的收藏夹中有这样的文件:

{
"_id" : NumberLong("26130948889"),
"segment" : {
    "name" : "A Fake Name",
    "category" : 3
    "location" : {
        "type" : "Point",
        "coordinates" : [
            41.16364669799805,
            -3.0703139305114746
        ]
    },
    "other-relevant-data" : 9.199999809265137
},
"elapsedTime" : NumberLong(2016)}

并想要这样的事情:

{[
"_id" : NumberLong("26405224704")
"segment" : {
    "name" : "Fake Name 1",
    "category" : 2,
    "location" : {
        "type" : "Point",
        "coordinates" : [
            40.785404205322266,
            -3.9882829189300537
        ]
    },
    "other-relevant-data" : 11.899999618530273
},
"elapsedTime" : NumberLong(1265)},{
"_id" : NumberLong("26405224730"),
"segment" : {
    "name" : "Fake Name 2",
    "Category" : 5, 
    "end" : {
        "type" : "Point",
        "coordinates" : [
            40.78533935546875,
            -3.987668037414551
        ]
    },
    "other-relevant-data" : 7.300000190734863
},
"elapsedTime" : NumberLong(4557)}],[{
"_id" : NumberLong("26130948889"),
"segment" : {
    "name" : "A Fake Name",
    "category" : 3
    "location" : {
        "type" : "Point",
        "coordinates" : [
            41.16364669799805,
            -3.0703139305114746
        ]
    },
    "other-relevant-data" : 9.199999809265137
},
"elapsedTime" : NumberLong(2016)}]

0 个答案:

没有答案