text
Indextext
索引的名称¶On this page本页内容
Changed in MongoDB 4.2
Starting in version 4.2, for featureCompatibilityVersion set to 从4.2版开始,对于设置为“4.2”或更高版本的"4.2"
or greater, MongoDB removes the Index Name Length
limit of 127 byte maximum. featureCompatibilityVersion
,MongoDB删除了最大127字节的索引名长度限制。In previous versions or MongoDB versions with featureCompatibilityVersion (fCV) set to 在featureCompatibilityVersion(fCV)设置为“4.0”的早期版本或MongoDB版本中,索引名必须在限制范围内。"4.0"
, index names must fall within the limit
.
The default name for the index consists of each indexed field name concatenated with 索引的默认名称由每个与_text
. _text
连接的索引字段名组成。For example, the following command creates a 例如,下面的命令在text
index on the fields content
, users.comments
, and users.profiles
:content
、users.comments
和users.profiles
字段上创建文本索引:
The default name for the index is:索引的默认名称为:
text
Indextext
索引的名称¶You can pass the 您可以将name
option to the db.collection.createIndex()
method:name
选项传递给db.collection.createIndex()
方法:
text
Indextext
索引¶Whether the text index has the default name or you specified a name for the text index, to drop the text index, pass the index name to the 无论文本索引具有默认名称还是指定了文本索引的名称,要删除文本索引,请将索引名称传递给db.collection.dropIndex()
method.db.collection.dropIndex()
方法。
For example, consider the index created by the following operation:例如,考虑以下操作创建的索引:
Then, to remove this text index, pass the name 然后,要删除此文本索引,请将名称"MyTextIndex"
to the db.collection.dropIndex()
method, as in the following:"MyTextIndex"
传递给db.collection.dropIndex()
方法,如下所示:
To get the names of the indexes, use the 要获取索引的名称,请使用db.collection.getIndexes()
method.db.collection.getIndexes()
方法。