i have the following collection:
books> db.books.find()
[
{
_id: ObjectId("61ab85b0056b5357b5e23e6b"),
fields: 'hello good morning'
},
{ _id: ObjectId("61ab85b5056b5357b5e23e6c"), fields: 'good morning' },
{
_id: ObjectId("61ab8679056b5357b5e23e6d"),
fields: 'hello good morning guys'
},
{
_id: ObjectId("61ab8684056b5357b5e23e6e"),
fields: 'good morning guys'
}
]
Then, i run this query:
db.books.find({$text : {$search : "\"good morning\" hello"}})
and i get:
[
{ _id: ObjectId("61ab85b5056b5357b5e23e6c"), fields: 'good morning' },
{
_id: ObjectId("61ab8684056b5357b5e23e6e"),
fields: 'good morning guys'
},
{
_id: ObjectId("61ab85b0056b5357b5e23e6b"),
fields: 'hello good morning'
},
{
_id: ObjectId("61ab8679056b5357b5e23e6d"),
fields: 'hello good morning guys'
}
]
Can you help me to understand the output? The first result doesn't make much sense to me (document _id : ...23e6c), as it doesn't contain the "hello" string.
I read the first answer to this question. Does it mean that, in my case, mongodb is searching for
(good morning) AND (good OR morning OR hello)
It would explain my question, but i can't find the exact reference to this in the mongodb documentation
Thanks in advance