- Indexes >
- Text Indexes >
- Specify Name for
text
Index
Specify Name for text
Index¶
Changed in MongoDB 4.2
Starting in version 4.2, for featureCompatibilityVersion set to "4.2"
or greater, MongoDB removes the
Index Name Length
limit of 127 byte maximum. In previous
versions or MongoDB versions with
featureCompatibilityVersion (fCV) set to
"4.0"
, index names must fall within the
limit
.
The default name for the index consists of each indexed field name
concatenated with _text
. For example, the following command creates
a text
index on the fields content
, users.comments
, and
users.profiles
:
The default name for the index is:
Specify a Name for text
Index¶
You can pass the name
option to the
db.collection.createIndex()
method:
Use the Index Name to Drop a text
Index¶
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.
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:
To get the names of the indexes, use the
db.collection.getIndexes()
method.