Uploaded image for project: 'Documentation'
  1. Documentation
  2. DOCS-5263

createIndexes command and the ns index option

    XMLWordPrintableJSON

Details

    Description

      The createIndexes command documentation mentions that ns may be specified when creating an index and will be generated by MongoDB if omitted.

      Since the command is executed with a specific database and collection, I curiously tried to see how different ns values were handled. Testing against 3.0 showed that the command fails with a "namespace mismatch" error message if the ns for any index specifies a different database or collection. I'm not surprised, but the documentation lead me to believe that I could specify other namespaces. Perhaps we should clarify that the ns option, if specified, must correspond to the database and collection of the command.

      If I had to guess, ns was a relic from documentation of the legacy index creation method (i.e. inserting into system.indexes), which would have allowed different namespaces to be specified (of various collections, albeit in the same database).

      Attachments

        Activity

          People

            steve.renaker@mongodb.com Steve Renaker (Inactive)
            jmikola@mongodb.com Jeremy Mikola
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              7 years, 46 weeks ago