|
Create the index:
db.collection.ensureIndex({ words: "text", additional: 1 })
|
db.collection.getIndexes()
|
[
|
{
|
"v": 1,
|
"key": {
|
"_id": 1
|
},
|
"ns": "test.collection",
|
"name": "_id_"
|
},
|
{
|
"v": 1,
|
"key": {
|
"_fts": "text",
|
"_ftsx": 1,
|
"additional": 1
|
},
|
"ns": "test.collection",
|
"name": "words_text_additional_1",
|
"weights": {
|
"words": 1
|
},
|
"default_language": "english",
|
"language_override": "language",
|
"textIndexVersion": 1
|
}
|
]
|
reIndex() reorders fields:
db.collection.reIndex()
|
[
|
{
|
"v": 1,
|
"key": {
|
"_id": 1
|
},
|
"ns": "test.collection",
|
"name": "_id_"
|
},
|
{
|
"v": 1,
|
"key": {
|
"additional": 1,
|
"_fts": "text",
|
"_ftsx": 1
|
},
|
"ns": "test.collection",
|
"name": "words_text_additional_1",
|
"weights": {
|
"words": 1
|
},
|
"default_language": "english",
|
"language_override": "language",
|
"textIndexVersion": 1
|
}
|
]
|
At this point the index cannot be used as the additional field must appended and not a prefix.
|