I was told a scenario(you will find in the middle of this blog) and asked which one is more appropriate to store and retrieve data, Elastic or Mongo? Unfortunately I was not able to give a convincing answer in less than a minute.
All I could tell was, both are document based and use JSON format. Elastic is index based and MongoDB is NoSQL. As you can see, this information gives no clear justification to choose between either of the two technologies for any scenario.
So, I thought I will write a shortest comprehension possible to explain both in a nutshell. After reading this post, you would be able to select the most relevant one by just looking at my use case.
I added my problem statement and at the end of this blog I also added the solution I suggested.
If you are able to figure out the relevant one, HURRAY!! You understood both the techs and can make decisions on selecting between the two for your use cases.
Problem Statement: I want to have an application that stores documents which is readily available to the users as soon as I publish. I also want to have a search engine to crawl inside the documents and get the most relevant results.
First of all, What is the sole purpose of both? Why even these two exist when we have traditional RDBMS
Before I start, I assume you have an idea about RDBMS, indexing and clustering in Data storage.
It is a document based storage and retrieval system, that means it is schema-less (No tables and rows as SQL has). Indexing and clustering is its major capabilities. Say, when I have millions of data and I just want to zoom out of the data and find the patterns, I would be able to do it with indexing. Clustering allows to group the data with appropriate relevance that boosts up the search speed significantly.
Another thing about elastic search, I like the most is, its Auto completion and auto correctness feature, which you would be able to find in a typical search engine like google. In fact, Elastic search itself runs on top of a open source search engine called Apache Lucene.