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

Should forbid creating > 1 text index

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

      The documentation for text indexes says that "A collection can have at most one text index," but I can create several without receiving any kind of error message. I receive an error message only when I try to do a text search.

      > db.tc.findOne()
      { "_id" : ObjectId("52447ea78917a9cc8fdf516a"), "a" : "asdf", "b" : "qwer" }
      > db.tc.ensureIndex({"a":"text"})
      > db.tc.ensureIndex({"b":"text"})
      > db.getLastError()
      null
      > db.tc.getIndexes()
      [
      	{
      		"v" : 1,
      		"key" : {
      			"_id" : 1
      		},
      		"ns" : "qa370.tc",
      		"name" : "_id_"
      	},
      	{
      		"v" : 1,
      		"key" : {
      			"_fts" : "text",
      			"_ftsx" : 1
      		},
      		"ns" : "qa370.tc",
      		"name" : "a_text",
      		"weights" : {
      			"a" : 1
      		},
      		"default_language" : "english",
      		"language_override" : "language",
      		"textIndexVersion" : 1
      	},
      	{
      		"v" : 1,
      		"key" : {
      			"_fts" : "text",
      			"_ftsx" : 1
      		},
      		"ns" : "qa370.tc",
      		"name" : "b_text",
      		"weights" : {
      			"b" : 1
      		},
      		"default_language" : "english",
      		"language_override" : "language",
      		"textIndexVersion" : 1
      	}
      ]
      > db.tc.stats()
      {
      	"ns" : "qa370.tc",
      	"count" : 10002,
      	"size" : 1120176,
      	"avgObjSize" : 111.99520095980805,
      	"storageSize" : 1396736,
      	"numExtents" : 5,
      	"nindexes" : 3,
      	"lastExtentSize" : 1048576,
      	"paddingFactor" : 1,
      	"systemFlags" : 0,
      	"userFlags" : 1,
      	"totalIndexSize" : 1430800,
      	"indexSizes" : {
      		"_id_" : 335216,
      		"a_text" : 555968,
      		"b_text" : 539616
      	},
      	"ok" : 1
      }
      > db.tc.runCommand("text", {search:"asdf"})
      { "ok" : 0, "errmsg" : "too many text index for: qa370.tc" }
      

      It seems as if it would be better to print an error message as soon as a second text index is attempted and especially not build or maintain the second index at all, which seems like what's happening here.

            Assignee:
            Unassigned Unassigned
            Reporter:
            luke.lovett Luke Lovett
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: