使用多种语言的mongodb文本搜索

编程入门 行业动态 更新时间:2024-10-22 23:48:11
本文介绍了使用多种语言的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?

推荐答案

您具体的意思是: 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文本搜索

本文发布于:2023-10-18 13:08:16,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1504314.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文本   多种   语言   mongodb

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!