Details
-
Improvement
-
Resolution: Done
-
Minor - P4
-
None
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).