Uploaded image for project: 'Compass '
  1. Compass
  2. COMPASS-7786

Issue with projection query syntax after migrating to atlas( From version 3 to 5 mongodb driver)

    • Type: Icon: Bug Bug
    • Resolution: Incomplete
    • Priority: Icon: Major - P3 Major - P3
    • No version
    • Affects Version/s: None
    • Component/s: None
    • Environment:
      OS: MAC OS
      Additional info:
    • Not Needed
    • Developer Tools

      Problem Statement/Rationale

      I'm facing issue with projection query syntax after migrating to atlas, I have upgraded mongodb driver from version 3 to 5, when i try running project query in atlas, I'm facing this error : 

      Failed to retrieve documents[lk_uat.ivrTreeConfig@Uat atlas [replica set: atlas-6mtsco-shard-0]] Database error!Stacktrace: 
      |_/ java.lang.Exception: [lk_uat.ivrTreeConfig@Uat atlas [replica set: atlas-6mtsco-shard-0]] Database error!
      |____/ Mongo Server error (MongoQueryException): Query failed with error code 31250 with name 'Location31250' and error message 'Path collision at solutions' on server lk-mongo-uat-01-shard-00-02.y3cij.mongodb.net:27017 

       

       

      Steps to Reproduce

      Table contents :

       

      
      

      *

      { "_id" : ObjectId("5ea87643ce371e745912e21c"), "name" : "A", "description" : "Description...", "text" : [ \{ "name" : "A_1", "text" : "Content1" }

      ,
      {
      "name" : "A_2",
      "text" : "Content2"
      }
      ],
      "solutions" : [
      {
      "text" : "1",
      "action" : "A"
      },
      {
      "text" : "2",
      "action" : "B"
      },
      {
      "text" : "",
      "action" : "A"
      },
      {
      "text" : "12",
      "action" : "C"
      },
      {
      "text" : "11",
      "action" : "D"
      }
      ]
      }*

      Query when version 3 of mongoDB 

       

       

      db.getCollection("ivrTreeConfig").find({ "name" : "A", "$and" : [{ "solutions" : { "$elemMatch" : { "text" : "2" } } }] },
      { "solutions.$" : 1,  "solutions" : 1,"action" : 1 });

       

      Expected Results

       

      {
          "_id" : ObjectId("5ea87643ce371e745912e21c"),
          "solutions" : [
              {
                  "text" : "2",
                  "action" : "B"
              }
          ]
      }
      

      Actual Results

       

      Failed to retrieve documents[lk_uat.ivrTreeConfig@Uat atlas [replica set: atlas-6mtsco-shard-0]] Database error!Stacktrace:  |_/ java.lang.Exception: [lk_uat.ivrTreeConfig@Uat atlas [replica set: atlas-6mtsco-shard-0]] Database error! |____/ Mongo Server error (MongoQueryException): Query failed with error code 31250 with name 'Location31250' and error message 'Path collision at solutions' on server lk-mongo-uat-01-shard-00-02.y3cij.mongodb.net:27017 

       

      Additional Notes

      But I can achieve the same result after mongoDB version upgrade with this query

       

       db.getCollection("ivrTreeConfig").find({ "name" : "A", "$and" : [{ "solutions" : { "$elemMatch" : { "text" : "2" } } }] },
      { "_id": 1, "solutions.$": 1});

      Can i know why the projection query is not working in the the newer version or atlas, If you could provide me documentation of the same 

       

            Assignee:
            Unassigned Unassigned
            Reporter:
            ashish.singh@lendingkart.com Ashish Singh
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: