So, according to the MongoDB docs,
if the document field contains the word blueberry, a search for the term blue will not match the document
This is good for my use case, this is what I want. However, given the following entries in the database:
> db.test.drop() > db.test.insert({ "t" : "Men Fashion" }) > db.test.insert({ "t" : "Women Fashion" }) > db.test.ensureIndex({ "t" : "text" })
A search for men returns the expected results:
> db.test.find({ "$text" : { "$search" : "\"Men's\"" } }, { "_id" : 0 }) { "t" : "Men Fashion" }
However, searching for the entire phrase Men Fashion, unexpectedly also returns Women Fashion:
> db.test.find({ "$text" : { "$search" : "\"Men Fashion\"" } }, { "_id" : 0 }) { "t" : "Women Fashion" } { "t" : "Men Fashion" }
I tried "\"Men's\"\"Fashion\"" also with the same results. Is there any workaround / trick to get the full phrase to return whole words?
I am using Mongo 2.6.4. Interestingly, it scores women lower than men.
source share