Incorrect results for $elemMatch-$not when index is hinted

XMLWordPrintableJSON

    • Query Optimization
    • ALL
    • Hide
      const coll = db.coll;
      coll.drop()
      coll.insert({
          "_id" : 122,
          "a" : NumberInt(0)
      })
      
      const q = [
      	{
      		"$match" : {
      			"a" : {
      				"$elemMatch" : {
                          "$nin" : [ ]
      				}
      			}
      		}
      	},
      	{
      		"$project" : {
      			"_id" : 0,
      			"a" : 1
      		}
      	}
      ];
      
      jsTestLog(coll.aggregate(q).toArray())
      // [ ]
      jsTestLog(coll.aggregate(q, {hint: '_id_'}).toArray())
      // [ { "a" : 0 } ]
      
      Show
      const coll = db.coll; coll.drop() coll.insert({ "_id" : 122, "a" : NumberInt(0) }) const q = [ { "$match" : { "a" : { "$elemMatch" : { "$nin" : [ ] } } } }, { "$project" : { "_id" : 0, "a" : 1 } } ]; jsTestLog(coll.aggregate(q).toArray()) // [ ] jsTestLog(coll.aggregate(q, {hint: '_id_' }).toArray()) // [ { "a" : 0 } ]
    • 200
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      See repro above.

            Assignee:
            Alexander Ignatyev
            Reporter:
            Matt Boros
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated: