使用多种语言的mongodb文本搜索 [英] mongodb text search using multiple languages

查看:62
本文介绍了使用多种语言的mongodb文本搜索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个字段的收藏集

{
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?

推荐答案

您具体的意思是: http://docs.mongodb.org/manual/tutorial/create-text-index我想在多语言集合上/#use-any-field来指定文档的语言,它使您可以覆盖整个文档的语言以及特定字段的值.

You specifically meant: http://docs.mongodb.org/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版本中使用此功能.您可以在 https://jira.mongodb.org/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 https://jira.mongodb.org/browse/SERVER-9390

这篇关于使用多种语言的mongodb文本搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆