Wildcard indexes produce incomplete explain output due to key collision

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Unresolved
    • Priority: Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: None
    • Query Optimization
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Running the following on the legacy mongo shell vs mongosh produces different outputs:

      db.a.drop()
      db.a.createIndex({a:1, "b.$**":1, c: 1})
      db.a.insertOne({})
      db.a.explain().find({a:1, c: 1}).finish().queryPlanner.winningPlan.inputStage.indexBounds
      

      On mongosh:

      {
        a: [ '[1, 1]' ],
        '$_path': [ '[MinKey, MaxKey]' ],
        c: [ '[MinKey, MaxKey]' ]
      }
      

      On the legacy mongo shell:

      {
              "a" : [
                      "[1.0, 1.0]"
              ],
              "$_path" : [
                      "[MinKey, MinKey]",
                      "[\"\", {})"
              ],
              "c" : [
                      "[MinKey, MaxKey]"
              ]
      }
      

      Neither is actually correct. The object really contains two $_path keys, and the legacy shell shows the first occurance, while mongosh shows the second. This is confusing and misleading.

            Assignee:
            Unassigned
            Reporter:
            Kartal Kaan Bozdogan
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: