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

Support 2d index on time-series collection metadata fields

    XMLWordPrintable

Details

    • Task
    • Status: Closed
    • Major - P3
    • Resolution: Done
    • None
    • None
    • Storage
    • None
    • Execution Team 2021-07-12, Execution Team 2021-08-09

    Description

      Because metadata does not vary within a bucket, geo indexes on metadata can use an ordinary geo index on the time-series buckets collection.

      For example,

      {
      	createIndexes: “abc”,
      	indexes: [ { key: { “metaFieldName.a” : "2d" } } ]
      }
      
      

      will become

      {
      	createIndexes: “system.buckets.abc”,
      	indexes: [ { key: { “meta.a” : "2d" } } ]
      }
      

       

       

       

      JS test code

      assert.eq(1,
                timeseriescoll.find({[metaFieldName]: {$near: [0, 0]}}).toArray().length,
                "Failed to use index: " + tojson(twoDTimeseriesIndexSpec));
      

      JS test logs

      [js_test:timeseries_special_indexes] uncaught exception: Error: error: {
      [js_test:timeseries_special_indexes] 	"ok" : 0,
      [js_test:timeseries_special_indexes] 	"errmsg" : "$geoNear, $near, and $nearSphere are not allowed in this context",
      [js_test:timeseries_special_indexes] 	"code" : 2,
      [js_test:timeseries_special_indexes] 	"codeName" : "BadValue"
      [js_test:timeseries_special_indexes] } :
      [js_test:timeseries_special_indexes] _getErrorWithCode@src/mongo/shell/utils.js:25:13
      [js_test:timeseries_special_indexes] DBCommandCursor@src/mongo/shell/query.js:711:15
      [js_test:timeseries_special_indexes] DBQuery.prototype._exec@src/mongo/shell/query.js:113:28
      [js_test:timeseries_special_indexes] DBQuery.prototype.hasNext@src/mongo/shell/query.js:288:5
      [js_test:timeseries_special_indexes] DBQuery.prototype.toArray@src/mongo/shell/query.js:342:12
      [js_test:timeseries_special_indexes] @jstests/core/timeseries/timeseries_special_indexes.js:170:11
      [js_test:timeseries_special_indexes] @jstests/core/timeseries/timeseries_special_indexes.js:18:2
      [js_test:timeseries_special_indexes] failed to load: jstests/core/timeseries/timeseries_special_indexes.js
      

      Note: the same query on the corresponding buckets collection works fine, so the index is created via the time-series collection, we just can't use it.

      Attachments

        Issue Links

          Activity

            People

              dan.larkin-york@mongodb.com Dan Larkin-York
              dianna.hohensee@mongodb.com Dianna Hohensee
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: