针对文本“其他"的文本搜索查询.总是没有结果? [英] Text search query for text "other" always returns no results?

查看:64
本文介绍了针对文本“其他"的文本搜索查询.总是没有结果?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的数据如下:

[{"id" : 1, "question" : "Other specified dermatomycoses", ... },
 {"id" : 6, "question" : "Other specified disorders of joint, site unspecified", ... }]

加上一些其他记录.

如果我跑步

db.questions.find({$text:{$search:'other'}}).count()

我总是得到0.但是如果我跑步

I always get 0. But if I run

db.questions.find({$text:{$search:'specified'}}).count()

我得到了我期望的2.大多数搜索都可以正常工作,但不能使用其他"一词.有什么想法吗?

I get the 2 that I expect. Most searches work properly, but not the word "other". Any ideas?

推荐答案

这是许多引擎上文本搜索"操作中的常见现象,在标记化的单词中因此总是总是省略停用词" .

This is a commonplace occurance in "text search" operations on many engines, where "stop words" are always omitted from the words that are tokenized and therefore searchable.

常用词是"the","and","then"等.但是完整列表可以在

Common words are "the", "and", "then" etc. But the full listings can be viewed in the source tree. stop_words_[language].txt.

此处为英语列表

如果您要匹配此处列出的单词,请使用改为$regex 搜索:

If your intent is to match words such as listed there, then use a $regex search instead:

db.questions.find({ "question": { "$regex": "other" } })

这并不是MongoDB真正的事情,但是它在大多数文本搜索引擎中都会发生,并且是设计使然"的.

This is not really a MongoDB thing, but it happens with most text search engines, and is "by design".

这篇关于针对文本“其他"的文本搜索查询.总是没有结果?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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