【问题标题】:MongoDB 'unable to create 2dsphere index and find index for $geoNear query inMongoDB'无法创建 2dsphere 索引并为 $geoNear 查询找到索引
【发布时间】:2017-03-24 02:10:01
【问题描述】:

我的收藏

{"_id" : ObjectId("58240d6eb3fe299a1f28bdf0"),
    "id" : NumberLong(52),
    "user_id" : NumberLong(2),
    "user_type" : "user",
    "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
        ]
    }

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

我有这个错误:

"ok" : 0,
"errmsg" : "Can't extract geo keys: { _id: ObjectId('58240d6eb3fe299a1f28bdf1'), id: 84, user_id: 2, user_type: \"wcities\", type_id: \"23621\", type: \"poi\", type_name: \"Alcatraz Island\", attending: 1, domain: \"Parrot\", track_time: \"2015-02-02 06:33:34\", latitude: \"37.82668800\", longitude: \"-122.42302500\", fb_postid: \"\", event_date: \"0000-00-00\", m_event_date: -62169984000, m_type_id: \"poi__23621\", loc: { type: \"Point\", coordinates: [ 37.826688, -122.423025 ] } }  longitude/latitude is out of bounds, lng: 37.8267 lat: -122.423",
"code" : 16755
}

【问题讨论】:

  • 创建集合时首先考虑记住坐标[,] ok.Not coordinates[,]

标签: java php mongodb


【解决方案1】:

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

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

更多关于geoJSON

【讨论】:

    猜你喜欢
    • 2014-06-05
    • 1970-01-01
    • 1970-01-01
    • 2016-09-30
    • 1970-01-01
    • 2023-04-01
    • 2021-10-28
    • 1970-01-01
    • 2015-01-06
    相关资源
    最近更新 更多