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

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

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Minor - P4
    • Resolution: Works as Designed
    • 4.4.13
    • None
    • None
    • 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 }}      } });  

    Description

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

       

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: