MongoDB'无法创建2dsphere索引并找到$ geoNear查询的索引

时间:2016-11-10 06:10:59

标签: java php mongodb

我的收藏

#include "OperandT.h"

template <typename T>
const T OperandT<T>::ZERO  = static_cast<T>( static_cast<float>(1e-7) );

创建索引 db.user_tracking.ensureIndex({“loc”:“2dsphere”})

我有这个错误:

{"_id" : ObjectId("58240d6eb3fe299a1f28bdf0"),
    "id" : NumberLong(52),
    "user_id" : NumberLong(2),
    "user_type" : "wcities",
    "type_id" : "399278",
    "type" : "poi",
    "type_name" : "Kala Ghoda Amphitheatre",
    "attending" : NumberLong(0),
    "domain" : "",
    "track_time" : "0000-00-00 00:00:00",
    "latitude" : "18.92728500",
    "longitude" : "72.83274200",
    "fb_postid" : "",
    "event_date" : "0000-00-00",
    "m_event_date" : NumberLong("-62169984000"),
    "m_type_id" : "poi__399278",
    "loc" : {
        "type" : "Point",
        "coordinates" : [
            18.927285,
            72.832742
        ]
    }

1 个答案:

答案 0 :(得分:0)

错误说明了longitude/latitude is out of bounds

只需查看此answer即可获得的范围。您的lng: 37.8267 lat: -122.423纬度超出了+ 90 / -90的范围。您需要更正包含此数据的文档。

更多关于geoJSON