feathers-mongodb-fuzzy-search
feathers-mongodb-fuzzy-search copied to clipboard
And Search
Hello there, what i'm trying to achieve is an AND search. Right now if my query string is " red blu" will find any document in which columns (fields) contains red OR blu. What i want here is a document with both red AND blu. (Mongodb).
I guess that's the default behaviour in mongo db, please try to either:
- setup a phrase to look for the compound "red blu" term (see https://docs.mongodb.com/manual/reference/operator/query/text/#phrases)
- perform 2 requests (one for "red" and one for "blu"), which is almost equivalent to a $or except you have to merge results manually, because I am not sure it is possible to make it work with mongo full text search in a single request (from the doc
MongoDB performs a logical OR search of the terms unless specified as a phrase
)
Mixing one input as a phrase and one as a term might do the job when limited to 2 terms (from the doc More specifically, the search performs a logical AND of the phrase with the individual terms in the search string
in https://docs.mongodb.com/manual/reference/operator/query/text/#phrases).