Elastic search is basically about indexing of data.

In database world,

Multiple indexes can be created on a MongoDB collection

Collection in MongoDB can be schema-less.

In MongoDB, BSON encoding of JSON syntax is used to communicate queries to MongoDB

In Elastic search, indexing is performed on such schema-less documents with JSON syntax.

1) I could not see the difference between,

  • indexing of a MongoDB collection


  • indexing in Elastic search

2) I would like to understand the value-add of indexing in Elastic search over indexing of a MongoDB collection.

3) Why would I use Elastic search, if I already index a MongoDB collection?


Why is elastic search so popular?

  • @Samuel 1) My understanding is, MongoDB is mostly used as a persistent layer of an application unlike RDBMS. RDBMS is an application(in itself) that ensures transaction(with ACID) & allow users to write triggers/stored-procedures for a table. MongoDB allowing CRUD operations is additional advantage over Elastic search. 2) Elastic search would also need storing data before performing search. Point is, infrastructure and input required for elastic search setup is not less than MongoDB setup Aug 20 '17 at 22:10

MongoDB is a database. Elasticsearch is a search engine. Since their aims are different, they have different priorities. MongoDB is focused on storing data consistently with good performance and to support different access patterns. Elasticsearch is focused on building low-latency indexes for search specifically text search. MongoDB does have full-text search (most databases do), but it's a feature, not the main focus of the database, so it may not have as many options and it may not be as performant as Elasticsearch.

I would like to understand the value-add of indexing in Elasticsearch over indexing of a MongoDB collection.

Specifically, take a look at MongoDB's text index documentation. It only supports a limited kind of query and index options. Elasticsearch supports many tokenization strategies, token filters, character filters, fuzzy matching, synonyms, and more.

Why Elasticsearch is so popular?

Most of your question is comparing MongoDB and Elasticsearch, but not everybody is using MongoDB. If you're using a RDBMS (e.g. PostgreSQL), it's very convenient to gather the search attributes and stick them in a search engine like Elasticsearch. In this case it doesn't make sense to use MongoDB because a RDBMS is already being used. We don't need another database, we need a search engine, and that's where Elasticsearch shines. If you're already using MongoDB you still may choose to use a dedicated search engine because it's probably faster than MongoDB, it puts less load on your OLTP database, and it has more search features.

  • Postgres may not be a good example, because it does support a decent full text search engine.
    – Lie Ryan
    Jul 18 '19 at 6:16

Not the answer you're looking for? Browse other questions tagged or ask your own question.