Timeseries indexes with partialFilterExpression created directly on buckets are returned untranslated

    • Type: Bug
    • Resolution: Unresolved
    • Priority: Minor - P4
    • None
    • Affects Version/s: 6.0.0, 7.0.0, 8.0.0, 8.2.0-rc0, 8.1.0
    • Component/s: None
    • None
    • Storage Execution
    • ALL
    • None
    • 3
    • TBD
    • None
    • None
    • None
    • None
    • None
    • None

      On timeseries collections one can create a "raw" index directly on the buckets collection. When listing the indexes over the main collection a reverse translation mechanism then translates the index back to user-visible fields. If the index is un-translatable then it is omitted from the listIndexes output:

      test> db.createCollection("a", {timeseries:{timeField:'t', metaField:'m'}})
      test> db.a.getIndexes()
      [
        { v: 2, key: { m: 1, t: 1 }, name: 'm_1_t_1' }
      ]
      test> db.system.buckets.a.createIndex({'meta.abc':1})
      test> db.a.getIndexes()
      [
        { v: 2, key: { m: 1, t: 1 }, name: 'm_1_t_1' },
        { v: 2, key: { 'm.abc': 1 }, name: 'meta.abc_1' }
      ]
      test> db.system.buckets.a.createIndex({'invalid':1})
      test> db.a.getIndexes()
      [
        { v: 2, key: { m: 1, t: 1 }, name: 'm_1_t_1' },
        { v: 2, key: { 'm.abc': 1 }, name: 'meta.abc_1' }
      ]
      

       

      However this omission mechanism only applies to the key field. If a partialFilterExpression is specified, then the index is never omitted, and the partialFilterExpression is returned as-is. This results in listIndexes returns a mix of translated and untranslated fields:

      test> db.system.buckets.a.createIndex({ 'meta.abc': 1 }, { partialFilterExpression: { 'meta.abc': 10 } })
      test> db.a.getIndexes()
      [
        { v: 2, key: { m: 1, t: 1 }, name: 'm_1_t_1' },
        { v: 2, key: { 'm.abc': 1 }, name: 'meta.abc_1', partialFilterExpression: { 'meta.abc': 10 }}
      ]
      test> db.system.buckets.a.createIndex({ 'meta.def': 1 }, { partialFilterExpression: { 'invalid': 10 } })
      test> db.a.getIndexes()
      [
        { v: 2, key: { m: 1, t: 1 }, name: 'm_1_t_1' },
        { v: 2, key: { 'm.abc': 1 }, name: 'meta.abc_1', partialFilterExpression: { 'meta.abc': 10 }},
        { v: 2, key: { 'm.def': 1 }, name: 'meta.def_1', partialFilterExpression: { invalid: 10 }}
      ]
      

       

      Note this only happens if raw indexes are created directly on the buckets.
      Indexes with a partialFilterExpression created over measurements will include an originalSpec field (SERVER-58779) that results in a correct translation.

       

      We should consider omitting raw bucket indexes with a partialFilterExpression but without an originalSpec.

            Assignee:
            Unassigned
            Reporter:
            Joan Bruguera Micó
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: