Emilla
Emilla

Reputation: 494

MongoDB Geospital compound indexing return error

I am trying to make an index over my collection in MongoDB. But I am getting error of

point not in interval of [ -180, 180 ]

This is the query I am trying to run.

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

And the structure of my document is below. I googled it but not found any satisifed solution really.

{
"_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
}

Upvotes: 1

Views: 83

Answers (1)

Ben Siver
Ben Siver

Reputation: 2948

The index you are setting up looks correct according to your document structure. What Mongo is telling you is that there is an entry in your database where the latitude or longitude falls outside of the allowed range.

Try running the following queries to confirm this:

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();

Upvotes: 1

Related Questions