Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-11836

$or with "special" query fails sometimes in 2.4, not in 2.5

    • Type: Icon: Bug Bug
    • Resolution: Won't Fix
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.4.9
    • Component/s: Querying
    • Environment:
    • ALL
    • Hide

      2.5.5-pre-

      > db.c.insert({loc:{type:"Point",coordinates:[0,0]}})
      Insert WriteResult({ "ok" : 1, "n" : 1 })
      > db.c.ensureIndex({loc:"2dsphere"})
      > db.c.find({$or:[{"loc":{$geoWithin:{$geometry:{type:"Polygon",coordinates:[[[1,1],[-1,1],[-1,-1],[1,-1],[1,1]]]}}}}]})
      { "_id" : ObjectId("528fcfc56ce2fec2710a1365"), "loc" : { "type" : "Point", "coordinates" : [  0,  0 ] } }
      > db.c.find({$or:[{"loc":{$geoWithin:{$geometry:{type:"Polygon",coordinates:[[[1,1],[-1,1],[-1,-1],[1,-1],[1,1]]]}}}}]}).sort({a:1})
      { "_id" : ObjectId("528fcfc56ce2fec2710a1365"), "loc" : { "type" : "Point", "coordinates" : [  0,  0 ] } }
      > db.c.find({$or:[{"loc":{$geoWithin:{$geometry:{type:"Polygon",coordinates:[[[1,1],[-1,1],[-1,-1],[1,-1],[1,1]]]}}}}]}).sort({a:1}).count()
      1
      

      2.4.9-pre-

      > db.c.insert({loc:{type:"Point",coordinates:[0,0]}})
      > db.c.ensureIndex({loc:"2dsphere"})
      > db.c.find({$or:[{"loc":{$geoWithin:{$geometry:{type:"Polygon",coordinates:[[[1,1],[-1,1],[-1,-1],[1,-1],[1,1]]]}}}}]})
      error: { "$err" : "$or may not contain 'special' query", "code" : 13291 }
      > db.c.find({$or:[{"loc":{$geoWithin:{$geometry:{type:"Polygon",coordinates:[[[1,1],[-1,1],[-1,-1],[1,-1],[1,1]]]}}}}]}).sort({a:1})
      { "_id" : ObjectId("528fcfc55142cd7d1e23d1c5"), "loc" : { "type" : "Point", "coordinates" : [  0,  0 ] } }
      > db.c.find({$or:[{"loc":{$geoWithin:{$geometry:{type:"Polygon",coordinates:[[[1,1],[-1,1],[-1,-1],[1,-1],[1,1]]]}}}}]}).sort({a:1}).count()
      Fri Nov 22 13:44:19.839 count failed: {
      	"errmsg" : "exception: $or may not contain 'special' query",
      	"code" : 13291,
      	"ok" : 0
      } at src/mongo/shell/query.js:180
      
      Show
      2.5.5-pre- > db.c.insert({loc:{type: "Point" ,coordinates:[0,0]}}) Insert WriteResult({ "ok" : 1, "n" : 1 }) > db.c.ensureIndex({loc: "2dsphere" }) > db.c.find({$or:[{ "loc" :{$geoWithin:{$geometry:{type: "Polygon" ,coordinates:[[[1,1],[-1,1],[-1,-1],[1,-1],[1,1]]]}}}}]}) { "_id" : ObjectId( "528fcfc56ce2fec2710a1365" ), "loc" : { "type" : "Point" , "coordinates" : [ 0, 0 ] } } > db.c.find({$or:[{ "loc" :{$geoWithin:{$geometry:{type: "Polygon" ,coordinates:[[[1,1],[-1,1],[-1,-1],[1,-1],[1,1]]]}}}}]}).sort({a:1}) { "_id" : ObjectId( "528fcfc56ce2fec2710a1365" ), "loc" : { "type" : "Point" , "coordinates" : [ 0, 0 ] } } > db.c.find({$or:[{ "loc" :{$geoWithin:{$geometry:{type: "Polygon" ,coordinates:[[[1,1],[-1,1],[-1,-1],[1,-1],[1,1]]]}}}}]}).sort({a:1}).count() 1 2.4.9-pre- > db.c.insert({loc:{type: "Point" ,coordinates:[0,0]}}) > db.c.ensureIndex({loc: "2dsphere" }) > db.c.find({$or:[{ "loc" :{$geoWithin:{$geometry:{type: "Polygon" ,coordinates:[[[1,1],[-1,1],[-1,-1],[1,-1],[1,1]]]}}}}]}) error: { "$err" : "$or may not contain 'special' query" , "code" : 13291 } > db.c.find({$or:[{ "loc" :{$geoWithin:{$geometry:{type: "Polygon" ,coordinates:[[[1,1],[-1,1],[-1,-1],[1,-1],[1,1]]]}}}}]}).sort({a:1}) { "_id" : ObjectId( "528fcfc55142cd7d1e23d1c5" ), "loc" : { "type" : "Point" , "coordinates" : [ 0, 0 ] } } > db.c.find({$or:[{ "loc" :{$geoWithin:{$geometry:{type: "Polygon" ,coordinates:[[[1,1],[-1,1],[-1,-1],[1,-1],[1,1]]]}}}}]}).sort({a:1}).count() Fri Nov 22 13:44:19.839 count failed: { "errmsg" : "exception: $or may not contain 'special' query" , "code" : 13291, "ok" : 0 } at src/mongo/shell/query.js:180

      Queries with the $or operator throw an error in the latest nightly for 2.4 when used with an array that contains any geospatial operator (described in error message as a "special" query). Version 2.5 does not throw this error.

            Assignee:
            Unassigned Unassigned
            Reporter:
            luke.lovett Luke Lovett
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: