First time using MongoDD. I have been combing the internet for hours trying to figure out what I am doing wrong. MongoDB is telling me that there is no index present after executing a geo query.
I have included the error. Any ideas?
The Schema
var locationPolygonSchema = new Schema({
type: {
type: String,
index: true,
default: 'Polygon'
},
loc: {
type: [Number],
index: '2dsphere'
}
});
var developerSchema = new Schema({
locationPolygon: locationPolygonSchema
});
developerSchema.index({locationPolygon: 1});
developerSchema.set('autoIndex', true);
The Document
{
...
locationCoords: [-122.47020789999999, 37.6879241]
locationName: "Daly City, CA, USA"
locationPolygon: {
type: "Polygon",
coordinates: [[[9129,1773], [8291, -4891]]]
},
locationRadius: 20
...
}
The Error
{
"$err": "Unable to execute query: error processing query: ns=whenrecruited.developers limit=21 skip=0" +
"Tree: GEONEAR field=locationPolygon maxdist=1.79769e+308 isNearSphere=0" +
"Sort: {}" +
"Proj: {}" +
"planner returned error: unable to find index for $geoNear query",
"code": 17007,
"message": "Unable to execute query: error processing query: ns=whenrecruited.developers limit=21 skip=0" +
"Tree: GEONEAR field=locationPolygon maxdist=1.79769e+308 isNearSphere=0" +
"Sort: {}" +
"Proj: {}" +
"planner returned error: unable to find index for $geoNear query",
"name": "MongoError"
}