Learn Powerful Full-Text Searches with MongoDB Atlas Search

Learn the Elasticsearch counterpart in MongoDB

Lynn G. Kwong

--

When it comes to full-text searches, the first tool we think of is normally Elasticsearch. It’s been true for quite some time in the past. However, things have changed because MongoDB also supports full-text searches now. The full-text search feature in MongoDB is called Atlas Search which also uses Apache Lucene as the core engine and thus the performance is comparable to that of Elasticsearch.

Image by DenisDoukhan on Pixabay.

Atlas Search is a strong competitor against Elasticsearch because you don’t need to maintain two clusters now, one for storing the data and another one for serving the data for searching. With Atlas Search, we can have the NoSQL database (mongod) and the full-text search engine (mongot) running in the same cluster and thus save the cost. More importantly, the domain-specific language (DSL) for the CRUD operations and the full-text searches are the same. Therefore, you don’t need to learn two different DSLs for storing data and searching data, respectively, which can make our work more efficient.

In this post, we will give a brief walk-through of the full-text feature of MongoDB Atlas Search to let you have a general understanding of it and can get started with it in your work.

We will continue to use the laptops collection in the products database we’ve been working on because the product names and attributes are good examples for using full-text searches.

If you haven’t used MongoDB or Atlas before, it’s recommended to have a quick refresh by these articles. Otherwise, you can continue to the following section.

If you want to follow along, please download this JSON file and use the following command to import the data to MongoDB Atlas. If you don’t have mongoimport installed yet, please follow this link to download and install the MongoDB Database Tools.

--

--

Lynn G. Kwong

I’m a Software Developer (https://medium.com/@lynn-kwong) keen on sharing thoughts, tutorials, and solutions for the best practice of software development.