json - Multiple $near in mongo 2.6.4 does not work -
i have collection document this:
{ ... "currentlocation" : { "type" : "point", "coordinates" : [ -92.48436693078111, 35.85223020932276 ] } ... }
and need create "$near" query 2 possible center points:
db.truck.find({ "$or": [{ "destinationlocation": { "$near": { "$geometry": { "type": "point", "coordinates": [-117.256875, 41.856405] }, "$maxdistance": 100000.0 } } }, { "destinationlocation": { "$near": { "$geometry": { "type": "point", "coordinates": [-112.256875, 40.856405] }, "$maxdistance": 100000.0 } } }] })
mongo returns me error:
error: { "$err" : "can't canonicalize query: badvalue many geonear expressions", "code" : 17287 }
is there way request $near 2 points except info union on application side? thanks.
mongo db accepts 1 near. , if there near, must either root or root must , and kid must near. see https://github.com/mongodb/mongo/blob/master/src/mongo/db/query/canonical_query.cpp#l733
if need $or
operation 2 $near
, seek create 2 queries , integrate results them.
json mongodb geolocation mongodb-query
No comments:
Post a Comment