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

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Works as Designed
    • Priority: 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 }}      } });  
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None
    • None

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

       

              Assignee:
              [HELP ONLY] Backlog - Triage Team
              Reporter:
              Yomi SEa
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: