MongoDB - Logical OR when searching for words and phrases using full-text search

Earlier I asked a question related to it, and as suggested by the poster, this new question created the following question:

MongoDB full text search - matching words and exact phrases

I had some problems with unexpected results when using full-text search in MongoDB, especially when searching for mixtures of words and phrases.

Using this useful example presented by the poster in the previous question ...

> db.test.drop()
> db.test.insert({ "t" : "I'm on time, not late or delayed" })
> db.test.insert({ "t" : "I'm either late or delayed" })
> db.test.insert({ "t" : "Time flies like a banana" })
> db.test.ensureIndex({ "t" : "text" })

> db.test.find({ "$text" : { "$search" : "time late delay" } }, { "_id" : 0 })
{ "t" : "I'm on time, not late or delayed" }
{ "t" : "Time flies like a banana" }
{ "t" : "I'm either late or delayed" }

> db.test.find({ "$text" : { "$search" : "late delay" } }, { "_id" : 0 })
{ "t" : "I'm on time, not late or delayed" }
{ "t" : "I'm either late or delayed" }

> db.test.find({ "$text" : { "$search" : "late delay \"on time\"" } }, { "_id" : 0 })
{ "t" : "I'm on time, not late or delayed" }

The first two queries behave as I expected, the first search for “time OR late delay OR”, and the second for “delay with delay OR”.

, http://docs.mongodb.org/manual/reference/operator/query/text/#phrases, , , "" OR delay AND ( " " ) ".

, " (" ") ?

+4
1

, , , MongoDB 2.6. MongoDB , (, Solr/, Lucene). , , " " "" ( ) (\ " " ) "" \ " \" ". , , ElasticSearch, , .

0

All Articles