问题
I'M trying to create a text index without a default language. The official docs specify If you specify a language value of "none", then the text search uses simple tokenization with no list of stop words and no stemming.
Hence I tried:
createIndex({aliases : "text"}, {name : "aliases_txt"}, {default_language: "none"})
However the created index ignores my option and has "english" as default language:
{
"v": 1,
"key": {
"_fts": "text",
"_ftsx": 1
},
"name": "aliases_txt",
"ns": "ner-dict.ents",
"weights": {
"aliases": 1
},
"default_language": "english",
"language_override": "language",
"textIndexVersion": 2
}
version: mongod-3.0.3
回答1:
In fact, in your solution, the name
value is ignored. If you want to specify both index name and default_language, you need to use:
db.textTest.createIndex({aliases : "text"}, {name : "aliases_txt", default_language: "none"});
with both name
and default_language
in the same 'options' document parameter.
回答2:
I just had to change the order:
db.ents.createIndex({aliases : "text"}, {default_language: "none"}, { name: "aliases_txt"})
来源:https://stackoverflow.com/questions/33879398/create-a-mongodb-text-index-with-no-default-language