My data looks like this:
[{"id" : 1, "question" : "Other specified dermatomycoses", ... },
{"id" : 6, "question" : "Other specified disorders of joint, site unspecified", ... }]
plus a few other records.
If I run
db.questions.find({$text:{$search:'other'}}).count()
I always get 0. But if I run
db.questions.find({$text:{$search:'specified'}}).count()
I get the 2 that I expect. Most searches work properly, but not the word "other". Any ideas?
Blakes said it all, as an added tip; you can use $language operator with value none to ignore stop words and stemming. Here is an example how to use it :
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:This is not really a MongoDB thing, but it happens with most text search engines, and is "by design".
When creating a text index in MongoDB, if you do not specify a language value it will use english by default and its stop words. If you want to be able to search by the stop words you will have to set the default language value of your text index to "none".
Create your index like this:
Then you should be able to run your query