1

我正在尝试为我在 MongoDB 中的集合创建索引。但我收到错误

point not in interval of [ -180, 180 ]

这是我要运行的查询。

db.col_name.ensureIndex({zloc:"2d",title:1,isPublished:1,finishDate:1});

我的文档结构如下。我用谷歌搜索了它,但没有真正找到任何满意的解决方案。

{
"_id": {
    "$oid": "518b758558266943c9ffa0d0"
},
"startDate": null,
"detail": "<p><strong>Fa&ccedil;iba Brunch Keyfi</strong><p>",
"imageUrl": [
    "http://img2.fbfcdn.com/files/images/deal/image/450_H/55/556101_fe85.jpg?r=3"
],
"isPublished": "on",
"category_id": 9,
"finishDate": null,
"webLink": "http://www.firsatbufirsat.com/firsat/",
"shopname": "Façiba & Deha Pansiyon & Restaurant & Cafe & Bar",
"publisher": "web",
"title": "Façiba'da Damak Zevkinize Hitap Edecek Açık Büfe Brunch Keyfi, Sucuklu Yumurta, Patates Tava ve Sınırsız Çay Eşliğinde 35 TL Yerine Sadece 18 TL",
"duration": 0,
"price": "18.00 TL",
"zloc": [
    41.144269,
    29.590859
],
"category_name": "Yemek Fırsatları",
"address": "Ahmetli Köyü Sortullu Mevkii İdeal Cad. No:9 Şile, İstanbul",
"user_id": null
}
4

1 回答 1

1

根据您的文档结构,您设置的索引看起来是正确的。Mongo 告诉您的是,您的数据库中有一个条目,其纬度或经度超出了允许的范围。

尝试运行以下查询来确认这一点:

db.col_name.find({"loc.lat": { $lt : -180 }}).count();
db.col_name.find({"loc.lat": { $gt : 180 }}).count();
db.col_name.find({"loc.long": { $lt : -180 }}).count();
db.col_name.find({"loc.long": { $lt : 180 }}).count();
于 2013-05-09T14:53:47.610 回答