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

Running the same createIndexes command twice with a text index, produces an odd error

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.5.5
    • Component/s: Index Maintenance
    • None
    • ALL

      When creating a duplicate normal index twice, you simply get a notification in the command return structure that tells you no indexes were created:

      > db.col1.runCommand({ 'createIndexes' : 'col1', indexes: [ { name: "e_1", key: { e: 1 } } ] } );
      {
      	"createdCollectionAutomatically" : false,
      	"numIndexesBefore" : 2,
      	"numIndexesAfter" : 3,
      	"ok" : 1
      }
      > db.col1.runCommand({ 'createIndexes' : 'col1', indexes: [ { name: "e_1", key: { e: 1 } } ] } );
      {
      	"numIndexesBefore" : 3,
      	"note" : "all indexes already exist",
      	"noChangesMade" : true,
      	"ok" : 1
      }
      

      But when we do this with a "text" column, then it fails with an error:

      > db.col1.runCommand({ 'createIndexes' : 'col1', indexes: [ { name: "d_1", key: { d: 'text' } } ] } );
      {
      	"createdCollectionAutomatically" : true,
      	"numIndexesBefore" : 1,
      	"numIndexesAfter" : 2,
      	"ok" : 1
      }
      > db.col1.runCommand({ 'createIndexes' : 'col1', indexes: [ { name: "d_1", key: { d: 'text' } } ] } );
      {
      	"ok" : 0,
      	"errmsg" : "Trying to create an index with same name d_1 with different key spec { d: \"text\" } vs existing spec { _fts: \"text\", _ftsx: 1 }",
      	"code" : 67
      }
      

            Assignee:
            Unassigned Unassigned
            Reporter:
            derick Derick Rethans
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: