You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

MongoDB 4.2.1全文搜索使用"none"语言时未返回预期结果

我在MongoDB 4.2.1版本中测试了多语言嵌套文档的全文搜索场景,使用的测试文档如下:

{ "_id" : "1", "t" : [ { "t" : "Stadt und Land and Fluss", "language" : "de" } ] }
{ "_id" : "2", "t" : [ { "t" : "City and Country und River", "language" : "en" } ] }

每个文档的文本通过嵌套对象里的language字段指定语言:文档1是德语,但文本中包含英语停用词and;文档2是英语,文本中包含德语停用词und。

接下来是四个测试场景的具体情况:

场景1:默认语言下搜索停用词

  • 查询语句:{ $text: { $search: "and" } }
    • 结果:无返回结果(看起来默认使用了英语停用词规则,and被过滤)
  • 查询语句:{ $text: { $search: "und" } }
    • 结果:返回文档1

场景2:使用"none"语言搜索停用词

  • 查询语句:{ $text: { $search: "and", $language: "none" } }
    • 结果:返回文档2
  • 查询语句:{ $text: { $search: "und", $language: "none" } }
    • 结果:返回文档1

场景3:默认语言下搜索普通词(符合预期)

  • 查询语句:{ $text: { $search: "City" } }
    • 结果:返回文档2
  • 查询语句:{ $text: { $search: "Stadt" } }
    • 结果:返回文档1

场景4:使用"none"语言搜索普通词

  • 查询语句:{ $text: { $search: "City", $language: "none" } }
    • 结果:无返回结果
  • 查询语句:{ $text: { $search: "Stadt", $language: "none" } }
    • 结果:返回文档1

我的期望

我希望MongoDB能够严格遵循每个文档指定的语言及其对应的停用词规则执行全文搜索,并且嵌套文档的结构不会影响这一行为。

内容的提问来源于stack exchange,提问作者SebastianStehle

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.09 07:22:34