Mongodb full-text matching matching precesion

I am trying to use mongodb full-text search to show the hint the user enters. I took all the necessary steps to create text indexes and enable full-text search in the database, and everything works fine, except for the accuracy of the results.

I used regexp to implement the same logic and, for example, when the user typed “blue”, then a sentence appeared containing “bluetooth” something similar to “blue *”, but using the full-text search mongos, I get only the result when I type 'bluetoot'.

I tried to use a symbol matching exactly the same as “blue” and any other imaginary combination that I could think of, but in vain.

So my question is, is there a way to implement this in mongo? and if mongo supports something like the * character used in regexp, or is the algorithm used trying to match the exact word?

Regards, Maximos

+4
source share
1 answer

MongoDB text search does not currently support partial word searches. The command corresponds to the full phrase - it is likely that “bluetooth” and “bluetoot” are associated with the same root, so this search query works, but “blue” does not. ( Source. ) MongoDB's text search uses the open-source Snowball trunk.

If you're still interested in implementing autocomplete, using regexp or an external autocomplete library (maybe Typeahead.js ?) Is probably your best bet. For example, if you want to offer article headers, you can cache the headers in a json file every few days and transfer that json data to Typeahead.js.

+6
source

Source: https://habr.com/ru/post/1493727/


All Articles