Adding Fuzziness to your Search Engine using MongoDB Altas

ksericpro
5 min readNov 19, 2023

Searching is a common feature in typical applications. Most search results are quite rigid, at most considered full-text search. Adding abit of fuzziness will make your application standout. Meaning if you search “erica”, it will return “erika”, “enrica”, “jan-eric”.

Let me show you how you can implement it using Mongo Altas and NodeJS. Do sign up a Sandbox account on Mongo Altas. This account only can upload up to maximum of 512M of data.

I will divide the setup into 4 parts:

MongoDB Altas: Setup Network Access, Create Database, Create Collection. Create User & Credentials, Create Search Index

MongoDB Compass: Setup, Save & Export Aggregation, Export Aggregation

NodeJS Setup: Install NPM dependencies, Modify Code Snippets, Edit Configuration

NodeJS Run: Start application, Search on browser

  1. MongoDB Altas

Security>Network Access

  • Allowing access from anywhere with 0.0.0.0/24 entry.
Add 0.0.0.0/24 entry to Network Access

Security>Database Access

  • Create “fuzzy_user”…

--

--