Is it posible a "fuzzy find"?

Hi everyone!

Now i am working in a search bar where i have products with brands and models:

query = { country, published: true, $or: [{}: this.req.query]}
allpublications = this.publicationmodel.find(query)

How can i perform it to make a “fuzzy query” in case someone misspell a word? Now i improve it with regex, but i don’t know if i can insert $text into it

Hi @Felipe_Lisperguer thanks for the question and welcome to the MongoDB community!

Supporting misspelled words is a great use case for Atlas Search. Among other relevance-based search features, the $search stage has a text operator which offers a fuzzy parameter that allows you to define how many character edits and different word variations to consider.

To get started with Atlas Search, you’ll have to create a *search index*. Once you have created your search index, you can construct a $search query using the text operator with fuzzy enabled.

You can also read more about the $search stage here.

I hope this helps! Please do not hesitate to reply if you have any other questions.

1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.