MongoDD を初めて使用します。私は自分が間違っていることを理解しようとして、何時間もインターネットをくまなく調べてきました。MongoDB は、地理クエリを実行した後、インデックスが存在しないと言っています。
エラーを含めました。何か案は?
スキーマ
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);
ドキュメント
{
...
locationCoords: [-122.47020789999999, 37.6879241]
locationName: "Daly City, CA, USA"
locationPolygon: {
type: "Polygon",
coordinates: [[[9129,1773], [8291, -4891]]]
},
locationRadius: 20
...
}
エラー
{
"$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"
}