Text search query for text “other” always returns no results?

后端 未结 3 812
生来不讨喜
生来不讨喜 2021-01-23 18:45

My data looks like this:

[{\"id\" : 1, \"question\" : \"Other specified dermatomycoses\", ... },
 {\"id\" : 6, \"question\" : \"Other specified disorders of join         


        
3条回答
  •  北荒
    北荒 (楼主)
    2021-01-23 18:57

    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.

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

    English list here

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

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

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

提交回复
热议问题