elasticsearch vs mongodb

Hypothetically both store data objects that have key-value pair, and allow querying that body of objects. But both come from 2 different camps and are made for different purposes.

MongoDB is a general purpose database, Elasticsearch is a distributed text search engine backed by Lucene. ElasticSearch is very good for specific task ? indexing and searching big datasets. It is used when you have some secondary info about your data and you need to know actual records to select. And since it?s architecture is optimized for this, it?s weaker in some other use cases. For example, in compare to many NoSQL databases ElasticSearch is slow on adding new data. In ElasticSearch Indexing semantics is defined on client side, so the actual indexing cannot be optimized as well as with real storages.

In practice, ElasticSearch is often used together with NoSQL and SQL databases, where database is used as persistent storage, and ElasticSearch is used for doing complex search queries, based on data content. For example, we at Mebelkart had used ElasticSearch for full-product catalog indexing, seller indexing, product reviews indexing, category indexing on top of MySql. We do all our read operations (complex queries) as well as Full text search from ElasticSearch Indexes. If you are building an application which requires too many filter or search operation ElasticSearch/Solr is the only best solution.

It is certainly possible to use Elasticsearch as a primary store but the best use of ElasticSearch is with any persistent storage No-Sql/MySql. Persistent storage system will provide you constraints, correctness and robustness, and you keep on pushing data to Elasticsearch on add or update.

ref: http://www.ranjeetvimal.com/elasticsearch-vs-mongodb/

23