我有两个字段的收藏集
{ name : 'text English', descr: 'Texto largo en español' }我想创建一个多语言搜索,并为名称提供更多首选项. 到目前为止,我一直在做这样的事情:
I would like to create a multi-language search, with more preferences for a name. Up till now I was doing something like this:
db.items.ensureIndex({ name : "text", descr : "text" },{ default_language: "spanish", name : "searchIndex", weights : { name : 3, descr: 1 } } )问题在于它会将所有内容都视为西班牙语.在文档中找到他们使用完全不同的架构.有什么想法可以实现我想要的吗?
The problem is that it treats everything as Spanish. Looking in the documentation I found that they are using completely different schema. Is there any idea to achieve what I want?
推荐答案您具体的意思是: docs.mongodb/manual/tutorial/create-text-index我想在多语言集合上/#use-any-field来指定文档的语言,它使您可以覆盖整个文档的语言以及特定字段的值.
You specifically meant: docs.mongodb/manual/tutorial/create-text-index-on-multi-language-collection/#use-any-field-to-specify-the-language-for-a-document I suppose, which allows you to override the language for a whole document with a specific field's value.
您想从问题中得到什么,在MongoDB中尚无法解决,但是计划在即将发布的MongoDB版本中使用此功能.您可以在 jira.mongodb/browse/SERVER-9390 上跟踪票证a>
What you want from your question, you can not do yet in MongoDB, but this feature is planned for the upcoming version of MongoDB. You can track the ticket at jira.mongodb/browse/SERVER-9390
更多推荐
使用多种语言的mongodb文本搜索
发布评论