12

I'm quite new to NoSql databases, but I'm really lovin' MongoDB with the official c# driver. It's currently the backend to an MVC application I'm writing, and the simplicity AND speed make my life way way easier.

However I've come to that point in the application where I need really great search. I used to use Solr, but have become quite interested in ElasticSearch.

ElasticSearch, as far as I can tell (from a very superficial level), can do everything MongoDB can in terms of being a document database.

So, if I'm already using a NoSql db, and I need great search, is there any point in Mongo? What's the use case?

Is Mongo faster? Easier to use? Is it the BSON datatypes and drivers? Why not use ElasticSearch as my DB?

I'm currently using AppHarbor and lovin' "The Cloud". I hate IT and want to focus on my application only. With that said, the only advantage I see so far is:

  • There are already a number of "Cloud" MongoDB providers. With ElasticSearch I've got to set it all up myself.
andy
  • 8,775
  • 13
  • 77
  • 122
  • Kind of broad. And I don't think fastest is the right criteria. For a small to mid sized app they all are going to produce good speed. Look a features and ease of development and support. Installing and environment is not that hard. How much to you hate IT? – paparazzo Jun 13 '12 at 20:41
  • 2
    In short: multi-key lookup. A bit longer a combo of ES + MongoDB is great, I'm using it in a website nearing production with 4+ years experience with Solr/Lucene, Membase, and other alternatives. Best practise, at least at works for me: keep your domain models in Mongo, have search in ES but only store the keys, and after an ES search do a key-lookup in Mongo. – Geert-Jan Jun 13 '12 at 21:51
  • 1
    @Geert-Jan why? When ES can return the doc at the same time as doing the multi-key lookup. What advantage do you have hitting ES and then mongo? – DrTech Jun 14 '12 at 11:42
  • 1
    The thing is, I don't like the idea of ES (or SOLR for that matter) to be the authorative source of my data. ES/Solr are specialized at search (and are fantastic at it) but I opt for a RDBMS or a mature NOSQL solution like Mongo for data safety/recovery, data inspection, etc. Moreover I need some CMS functionality on the data, like versioning, publish-flow, ACL-access control, etc. Good luck implementing that using ES/SOLR. Also frequent updates are expensive since for every changed property on a document the entire document has to be reindexed using ES/Solr – Geert-Jan Jun 14 '12 at 12:52
  • Who said that for ES??? "ES/Solr are specialized at search" – Karussell Jun 15 '12 at 07:25
  • There is at least one missunderstanding with lucene: "Also frequent updates are expensive" - it could be that you are right for certain documents .. but lucene is an append only storage where is mongodb will change big parts of its b tree in the worst case, so lucene could be even the better choice. AND: read some docs about why they switched away from mongo db ;) – Karussell Jun 15 '12 at 07:31
  • I have 0 experience with mongo db (so take my words with some distance ;)) but reading that and other docs: http://www.zopyx.de/blog/goodbye-mongodb I could come to the conclusion that mongo db does not scale as well as ES does and several features in ES are 'better' (querying multiple indices). – Karussell Jun 15 '12 at 07:36
  • ES providers are in the works, including my own http://bonsai.io/ – Nick Zadrozny Jun 21 '12 at 02:00
  • see http://stackoverflow.com/questions/3215029/nosql-mongodb-vs-lucene-or-solr-as-your-database. Not the same question as yours, Andy, but it has good discussion on the general topic. – SethO Sep 06 '12 at 14:00

1 Answers1

3

This is a very good question. I have asked myself the same question and came up with the following answer.

  1. ElasticSearch doesn’t have a good way to backup data. As an example, do a quick search for “ElasticSearch backup” and one for “mongodb backup”. MongoDB has tools and documentation on how to backup data. While there is documentation on how to backup ElasticSearch data, this documentation doesn’t seem as mature.
  2. In general, MongoDB has much better documentation. In particular its admin documentation is much better than ElasticSearch.
  3. MongoDB provides commercial support. You might not care about commercial support at the moment, but it is nice to know it is available.
  4. MongoDB has MapReduce built in, ElasticSearch does not. This may not be a big thing, but worth noting.

My personal opinion is that I wouldn’t use ElasticSearch if you cannot afford to lose data. I could see using ElasticSearch as a primary data store for something requiring real-time analytics, but did not have any long-term data retention requirements. Otherwise, I would suggest using MongoDB and ElasticSearch together. There is a MongoDB River Plugin for ElasticSearch. This makes it pretty easy to update the ElasticSearch index automatically.

Shawn H
  • 1,227
  • 1
  • 12
  • 18