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

$project expressions not working for documents inside arrays

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major - P3 Major - P3
    • None
    • None
    • Aggregation Framework
    • None
    • ALL
    • Hide

      1. Restore the attached value.json in any database
      2. Execute the below query, output is correct, review at "output query 1.png"
       
      db.salary.aggregate([{"$match":{"salary.amount":{$gte:5200}}}, {"$project":{"_id":0,"ID":1}} ]).toArray();
       
      3. Execute the below query, output is wrong, review at "output query 2.png"
       
      db.CaseDetail.aggregate([
      {"$match":{"caseAssignedTo":"153"}},
      {"$project":{"_id":0,"agreementNo":1,MI: {"$gte": ["$insuranceDetail.insuredAmount", 6000]}}} 
      ]).toArray();
      

      Show
      1. Restore the attached value.json in any database 2. Execute the below query, output is correct, review at "output query 1.png"   db.salary.aggregate([{"$match":{"salary.amount":{$gte:5200}}}, {"$project":{"_id":0,"ID":1}} ]).toArray();   3. Execute the below query, output is wrong, review at "output query 2.png"   db.CaseDetail.aggregate([ {"$match":{"caseAssignedTo":"153"}}, {"$project":{"_id":0,"agreementNo":1,MI: {"$gte": ["$insuranceDetail.insuredAmount", 6000]}}} ]).toArray();

    Description

      Match condition is not working inside projection for Embedded dcouments

      Attachments

        1. output query 1.png
          output query 1.png
          5 kB
        2. output query 2.png
          output query 2.png
          6 kB
        3. value.json
          0.6 kB

        Activity

          People

            Unassigned Unassigned
            guruskec guru rajan
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: