2016-05-06 6 views
0

私の場所コレクションに次の行があります。

{ "_id" : ObjectId("572b3892967c76c62b7f63e3"), "loc" : { "type" : "Point", "coordinates" : [ -73.97, 40.77 ] }, "name" : "Central Park", "category" : "Parks" } 

{ "_id" : ObjectId("572b38ba967c76c62b7f63e4"), "loc" : { "type" : "Point", "coordinates" : [ -73.88, 40.78 ] }, "name" : "La Guardia Airport", "category" : "Airport" } 

私は次のエラーを取得クエリ

db.places.find({$nearSphere: {$geometry: { type: "Point", coordinates: [-73.92, 40.775]}, $minDistance: 10000, $maxDistance: 10}}) 

次のコマンドを実行することはできませんよ。私は問題が何であるかを教えてください Error: error: { "$err" : "Can't canonicalize query: BadValue unknown top level operator: $nearSphere", "code" : 17287 }

を。

答えて

0

クエリオブジェクトには、「loc」フィールドがありません。また、minDistanceとmaxDistanceが間違っていると宣言したと思います。maxDistanaceminDistance。

私はあなたが欲しいクエリのようなものだと思う:

db.places.find({loc:{$nearSphere: {$geometry: { type: "Point", coordinates: [-73.92, 40.775]}, $minDistance: 10, $maxDistance: 10000}}}) 
関連する問題