0
の近くに私はこのようなモデルがあります:ループバック:オブジェクトのサブフィールド上のフィルタ
{
name: 'My Favorite Shop',
address:{
location: [12.534 /* longitude */ ,41.9221/* latitude */]
}
}
ドキュメントはMongoDBのデータベースに格納されているので、私はのようにそれらを照会したいと思います:
//assuming shops to be the name of the containing model
app.models.shops.find({
where: {
'address.location': {lat: 13, lng: 40}
}
}, callback);
このクエリは結果を取得しません。私はそれがにネストされているlocation
フィールドの性質のためだと思うが、私はそれを確認することができませんでした。
おかげ
UPDATE: それは私がデータソース定義でenableGeoIndexing
プロパティを設定するのを忘れて出てきました。クエリが完了すると、次のエラーが取得されます。
{"name":"MongoError","message":"Unable to execute query: error processing query: ns=acidata-dev.pos limit=25 skip=0\nTree: GEONEAR field=address.location maxdist=1.79769e+308 isNearSphere=0\nSort: {}\nProj: {}\n planner returned error: unable to find index for $geoNear query","$err":"Unable to execute query: error processing query: ns=acidata-dev.pos limit=25 skip=0\nTree: GEONEAR field=address.location maxdist=1.79769e+308 isNearSphere=0\nSort: {}\nProj: {}\n planner returned error: unable to find index for $geoNear query","code":17007}