Mongoose fuzzy query problem, to code friends for help

  mongodb, question

Problem description

For example, take the World Foreign Languages School as an example. When mongoose’s $regex is used for fuzzy matching, keywords such as world, foreign languages, etc. can be matched. However, when a keyword such as world, which jumps between words, cannot be matched.

The environmental background of the problem and what methods have you tried?

Problems Encountered When Doing Full Text Search

Related codes

//Please paste the code text below (please do not replace the code with pictures)

if(filter.s){
 condition.school = { $regex: filter.s };
 }

What is your expected result? What is the actual error message?

Expected Result: The input world can match the world foreign language school
Error Message: No error message, only no match

This has something to do with the way you write regular expressions. To achieve your goal, you need to do some extra strategies.

  1. Use input for direct matching, if there is no match to enter the second step
  2. Disassemble the input source, e.g. “outside the world”. Can be split into the world and the outside. The regularity of search is outside the world

There are many third-party libraries available for disassembly input. Can be broken down according to nouns and verbs