feathers-mongodb-fuzzy-search icon indicating copy to clipboard operation
feathers-mongodb-fuzzy-search copied to clipboard

And Search

Open Federico8 opened this issue 6 years ago • 1 comments

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).

Federico8 avatar Feb 28 '18 13:02 Federico8

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).

claustres avatar Mar 29 '18 13:03 claustres