[SERVER-10925] Should forbid creating > 1 text index Created: 26/Sep/13  Updated: 10/Dec/14  Resolved: 26/Sep/13

Status: Closed
Project: Core Server
Component/s: Index Maintenance
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Luke Lovett Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates SERVER-8127 Multiple text indexes per collection ... Closed
Operating System: ALL
Participants:

 Description   

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.



 Comments   
Comment by J Rassi [ 26/Sep/13 ]

Resolving as dup of SERVER-8127.

Generated at Thu Feb 08 03:24:24 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.