创建没有默认语言的mongodb文本索引 [英] Create a mongodb text index with no default language
问题描述
我正在尝试创建没有默认语言的文本索引.官方文档指定如果您将语言值指定为"none",则文本搜索将使用简单的标记化,没有停用词列表且没有词干.
因此,我尝试了:
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
}
版本: mongod-3.0.3
推荐答案
实际上,在您的解决方案中, name
值被忽略.如果要同时指定索引名称和default_language,则需要使用:
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"});
在相同的选项"文档参数中同时具有 name
和 default_language
.
with both name
and default_language
in the same 'options' document parameter.
这篇关于创建没有默认语言的mongodb文本索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!