title: Database needed with elasticsearch?
body: <p>I've been doing a lot of research in regards to elasticsearch and I seem to be stumbling on the question of whether or not a database is needed. </p>
  
  <p><strong>Current Hibernate-Search and Relational Design</strong></p>
  
  <p>My current application is written in java using hibernate, hibernate-search, and a mysql database. Hibernate search is built on lucene and automatically manages my indexes for me during database transactions. Hibernate-search will also search against the index and then pull full records from the database based on the stored pks rather than having to store your entire data model in the index. This has worked wonderfully, however as my application grows, I've continually run into scaling issues and cost do to the fact the Lucene indexes need to live on each application server and then you need another library to sync the indexes together. The other issue with this design is it requires more memory on all the application servers since the indexes are being replicated and stored with the application. </p>
  
  <p><strong>Database or No Database</strong></p>
  
  <p>Coming from the hibernate-search school of thought, I'm confused on whether or not your suppose to store your entire data model in elasticsearch and do away with the traditional database or if your suppose to store your search data in the indexes and again like hibernate-search return primary keys to pull complete records from your relational database. </p>
  
  <p><strong>Managing the Indexes</strong></p>
  
  <ol>
  <li>If your using the indexes with a a db, should you be manually
      maintaining them during transactions? I seen a jdbc project called
      river, but it looks to be deprecated and not recommended for
      production use, is there a library out there capable of
      automatically handling your transactions for you?</li>
  <li>If your indexes fall out of sync with your db, is there a recommended way to rebuild them?</li>
  </ol>
  
  <p><strong>Hibernate-Search API</strong></p>
  
  <p>I also seen the following in the hibernate-search roadmap
  API / SPI for alternative backends <a href="http://hibernate.org/search/roadmap/" rel="noreferrer">http://hibernate.org/search/roadmap/</a></p>
  
  <pre><code>Define API / SPI abstraction to allow for future external backends integrations such as Apache Solr and Elastic Search.
  </code></pre>
  
  <p>I'm wondering if anybody has any input on this? Is hibernate-search capable of managing the elastic search indexes automatically for you just as it does with it's native configuration?</p>
  
  <p><strong>If No Database</strong></p>
  
  <p>What would be the drawback of not using a database for anything search related?</p>