Using a $elemMatch with two $eq queries returns incorrect results

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Done
    • Priority: Major - P3
    • None
    • Affects Version/s: 3.2.0
    • Component/s: Shell
    • None
    • Environment:
      Windows Server 2008R2, MongoChef
    • ALL
    • Hide

      doc:

      { "STags" : [ "OD:52_domain.com", "OL:92_mlbx" ] }
      { "STags" : [ "OD:49_domain.com", "OL:92_mlbx" ] }
      

      Queries:

      db.test.find({"STags" : { $elemMatch : { $eq : "OD:52_domain.com", $eq : "OL:92_mlbx"} }})
      db.test.find({"STags" : { $elemMatch : { $eq : "OD:sdsfsfd", $eq : "OL:92_mlbx"} }})
      

      Both queries return two documents. even though 2nd query specifies a values that does NOT exist in any document.

      Replacing the $elemMath by a $and does not exhibit the same behaviour and returns the correct results.

      Show
      doc: { "STags" : [ "OD:52_domain.com", "OL:92_mlbx" ] } { "STags" : [ "OD:49_domain.com", "OL:92_mlbx" ] } Queries: db.test.find({"STags" : { $elemMatch : { $eq : "OD:52_domain.com", $eq : "OL:92_mlbx"} }}) db.test.find({"STags" : { $elemMatch : { $eq : "OD:sdsfsfd", $eq : "OL:92_mlbx"} }}) Both queries return two documents. even though 2nd query specifies a values that does NOT exist in any document. Replacing the $elemMath by a $and does not exhibit the same behaviour and returns the correct results.
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Using a $elemMatch with two $eq queries is returning all documents that only one of the $eq. And which one is matched depends on the order of the $eq in the statement.

            Assignee:
            Kelsey Schubert
            Reporter:
            Jason Mccullough
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved: