Answer the question
In order to leave comments, you need to log in
How to do a partial search in mongodb?
How to do a partial search in mongodb
now I do if I search like this:
db.content.find({$text: {$search: "Guard of the merchant"}})
then all records are displayed where the guard and the merchant meet,
but if you do this:
db .content.find({$text: {$search: "Guard"}}) then doesn't display anything, that is, it is now searching by words, if there is such a word guard, then it displays, but "guard" does not display,
Or if you search for "bargaining" then it searches only for the words bargaining and not everything where bargaining occurs (trading, etc.)
Answer the question
In order to leave comments, you need to log in
Mongo is not for such exercises.
If you still really need a Mongo-bike, then you need your own tokenizer and this can be done on N-Grams.
In general, you need to look towards Lucene / Solr / Elasticsearch.
MongoDB is not doing well with search now, especially in Russian. I tried to fix their stopword list, but there is an internal problem with index versioning. Until it is resolved, we should not expect any progress in the field of search by words.
Search by part of a word can be implemented using regular expressions, but this will not be very efficient and slow. al_gon says everything correctly, for text search, solutions are needed that are specially tailored for search.
You can specify the language in the index, then it will search for words with declensions ("book / books"),
There seems to be no full-text in monge, but you can manually break the text, for example "Guard" -> "ohr ohr ohr oh oh oh oh oh oh oh oh oh oh oh oh oh oh oh oh oh oh oh oh oh oh oh oh oh oh oh oh oh — then search for any part (from the beginning of the word), similarly, a search is made for any part of the word.
3-grams (n-grams) for misspelled searches.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question