【发布时间】:2016-07-16 07:46:40
【问题描述】:
这是我的文档模式
"translation" : {
"en" : {
"name" : "brown fox",
"description" : "the quick brown fox jumps over a lazy dog"
},
"it" : {
"name" : "brown fox ",
"description" : " the quick brown fox jumps over a lazy dog"
},
"fr" : {
"name" : "renard brun ",
"description" : " le renard brun rapide saute par-dessus un chien paresseux"
},
"de" : {
"name" : "brown fox ",
"description" : " the quick brown fox jumps over a lazy dog"
},
"es" : {
"name" : "brown fox ",
"description" : " el rápido zorro marrón salta sobre un perro perezoso"
}
},
现在我必须为上述文档添加文本索引。我怎样才能实现? 我已经在翻译中添加了文本索引,但这不起作用,因为名称和描述在语言前缀内(在对象内)。我还必须分别给出名称和描述的文本权重(文本分数)。即名称的文本分数为 5,描述的分数为 2。所以我不能给出通配符文本索引,即
{'$**': 'text'}
我也尝试使用'translation.en.name': 'text',但它不起作用,而且我的语言是动态的,所以这种情况的最佳解决方案是什么
任何帮助将不胜感激。
【问题讨论】:
-
您考虑更改文档结构并将动态键设为字段值。
{ "lang": "en", "name" : "brown fox", "description" : "the quick brown fox jumps over a lazy dog" } -
@SSDMS 你能否详细说明如何使用多个语言来实现这一点,即“de”或“ru”的索引
标签: mongodb meteor full-text-search