我有這個錯誤,當我嘗試查詢使用$ geoWithin幾何形狀或$ geoIntersects
error: { "$err" : "invalid operator: $geoWithin", "code" : 10068 }
我嘗試使用mongo v2.4.9來關注this example(在linux mint上,我必須說我無法更新到v2.4.9,所以我手動將/ usr/bin /中的二進制文件替換爲latest release中的二進制文件,我運行mongod - 之後升級)
以下是示例中的代碼:
s = db.shapes
s.insert({_id: "P1", shape: {type: "Point", coordinates: [2,2] } })
s.insert({_id: "P2", shape: {type: "Point", coordinates: [3,6] } })
s.insert({_id: "Poly1", shape: {type: "Polygon", coordinates: [[ [3,1], [1,2], [5,6], [9,2], [4,3], [3,1] ]] } })
s.insert({_id: "LS1", shape: {type: "LineString", coordinates: [ [5,2], [7,3], [7,5], [9,4] ] } })
s.ensureIndex({shape: "2dsphere"})
BOX = {type: "Polygon", coordinates: [[ [0,0], [3,0], [3,3], [0,3], [0,0] ]] }
s.find({shape: {$geoIntersects: {$geometry: BOX}}}, {_id:1})
那麼我:
error: { "$err" : "invalid operator: $geoIntersects", "code" : 10068 }
或
s.find({ shape : { $geoWithin : { $box : [ [ 0 , 0 ] , [ 100 , 100 ] ] } } })
那麼我:
error: { "$err" : "invalid operator: $geoWithin", "code" : 10068 }
這在OS X上正常工作與蒙戈2.4。 3
可以請你出示代碼 – meda