Uploaded image for project: 'MongoDB Shell'
  1. MongoDB Shell
  2. MONGOSH-2152

Make 2dsphere index options first class citizens in mongosh

    • Type: Icon: Task Task
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Shell API
    • None
    • None
    • Developer Tools

      Description

      Currently, customized index options for the 2dsphere index types (haven’t checked the 2d type - not sure) are ignored:

      test> db.geospatial.createIndex({l:"2dsphere"},{coarsestIndexedLevel: 8, finestIndexedLevel: 16})
      l_2dsphere
      test> db.geospatial.getIndexes()
      [
        { v: 2, key: { _id: 1 }, name: '_id_' },
        {
          v: 2,
          key: { l: '2dsphere' },
          name: 'l_2dsphere',
          '2dsphereIndexVersion': 3
        }
      ]

      Expected Results

      mongosh should support what server allows: https://github.com/mongodb/mongo/blob/0a68308f0d39a928ed551f285ba72ca560c38576/src/mongo/db/catalog/index_key_validate.h#L71-L98

      Actual Results

      Index options are ignored atm, even incorrect ones:

      test> db.geospatial.createIndex({l:"2dsphere"},{coarsestIndexedLevel: 8, finestIndexedLevel: 16, maxCellsInCovAAAAAering: 250})
      l_2dsphere

      Additional Notes

      mongosh version: 2.4.0

      If I create an index by using the correct createIndexes command, it works:

      test> db.runCommand({createIndexes:"geospatial", indexes: [{key:{l:"2dsphere"},name:"l_2dsphere",coarsestIndexedLevel: 8, finestIndexedLevel: 16}]})
      {
        numIndexesBefore: 1,
        numIndexesAfter: 2,
        createdCollectionAutomatically: false,
        ok: 1
      }
      test> db.geospatial.getIndexes()
      [
        { v: 2, key: { _id: 1 }, name: '_id_' },
        {
          v: 2,
          key: { l: '2dsphere' },
          name: 'l_2dsphere',
          '2dsphereIndexVersion': 3,
          coarsestIndexedLevel: 8,
          finestIndexedLevel: 16
        }
      ]

            Assignee:
            Unassigned Unassigned
            Reporter:
            anna.henningsen@mongodb.com Anna Henningsen
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: