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

Applying more than one search predicate on a Multi Key Indexed field.

    • Type: Icon: Bug Bug
    • Resolution: Works as Designed
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: 4.4.13
    • Component/s: None
    • Server Triage
    • ALL
    • Hide

      Sample Data:

      db.getCollection('foo').insertOne({
          "docArray" : [ {"code" : 10}, {"code" : 20}],
      });

       

      Query:  constantly false condition, a number can't be less than and greater than itself.

      db.getCollection('foo').find({
          "docArray.code" : { "$gt" : 13,  "$lt":13 }
      }); 

       

      Expected Result: 

      No Result

      Actual Result :

      Returns the inserted document

       

      Fixed Query:  a sample query that looks like has the expected behavior.

      db.getCollection('foo').find({
          "docArray" : { 
              "$elemMatch" : {"code" : { "$gt" : 13,  "$lt":13 }} 
          }
      });

       

      Show
      Sample Data: db.getCollection( 'foo' ).insertOne({     "docArray" : [ { "code" : 10}, { "code" : 20}], });   Query:   constantly false condition , a number can't be less than and greater than itself. db.getCollection( 'foo' ).find({     "docArray.code" : { "$gt" : 13,   "$lt" :13 } });   Expected Result:   No Result Actual Result : Returns the inserted document   Fixed Query:   a sample query that looks like has the expected behavior. db.getCollection( 'foo' ).find({     "docArray" : {          "$elemMatch" : { "code" : { "$gt" : 13,   "$lt" :13 }}      } });  

      Querying on an array of nested documents will split each search condition and apply them separately to the documents in the array.

       

            Assignee:
            backlog-server-triage [HELP ONLY] Backlog - Triage Team
            Reporter:
            p6tachi@gmail.com Yomi SEa
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: