# Using elasticsearch as my primary database

**URL:** https://discuss.elastic.co/t/using-elasticsearch-as-my-primary-database/9395
**Category:** Elasticsearch
**Created:** [October 17, 2012, 3:19pm UTC](https://discuss.elastic.co/t/using-elasticsearch-as-my-primary-database/9395 "2012-10-17T15:19:36Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Amy](https://avatars.discourse-cdn.com/v4/letter/a/4da419/32.png) [@Amy](https://discuss.elastic.co/u/Amy)
#### Post date: [October 17, 2012, 3:19pm UTC](https://discuss.elastic.co/t/using-elasticsearch-as-my-primary-database/9395/1 "2012-10-17T15:19:36Z")

</div>

Hi,  
I'm considering using elasticsearch as my primary db, the alternative being  
a couchbase-elasticsearch combo.  
Group discussions[https://groups.google.com/forum/?fromgroups=#!searchin/elasticsearch/primary$20database/elasticsearch/qAnXu5w3pn4/Te1vli7dfccJ](https://groups.google.com/forum/?fromgroups=#!searchin/elasticsearch/primary%2420database/elasticsearch/qAnXu5w3pn4/Te1vli7dfccJ)appear positive, but I have an issue that I have not seen discussed. If I  
want to change an index mapping, I need to flush the index. This deletes  
everything I have stored on Elasticsearch.  
Is there an alternative?

--

---

<div class="post-metadata">

### Author: ![radu\_gheorghe](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/radu_gheorghe/32/556_2.png) [@radu\_gheorghe](https://discuss.elastic.co/u/radu_gheorghe)
#### Post date: [October 17, 2012, 4:06pm UTC](https://discuss.elastic.co/t/using-elasticsearch-as-my-primary-database/9395/2 "2012-10-17T16:06:48Z")

</div>

Hello Amy,

If you add new fields to your mapping, it should work just fine  
(they're added to your current mapping). If you try to change the type  
of a certain field in your mapping, you will get an error, but  
flushing[0] the index doesn't delete your data.

If you need to change the type of a field (let's say from long to  
float), you have to reindex your data. You can do that on the live  
cluster by scrolling[1] through your data and indexing it in a  
different type where you have the new mapping.

Of course if your indices become corrupt for any reason (eg: file  
system failure), there's no getting away from backups. But that should  
be the same for any database.

## Best regards, Radu

[http://sematext.com/](http://sematext.com/) -- Elasticsearch -- Solr -- Lucene

[0] [Elastic — The Search AI Company | Elastic](http://www.elasticsearch.org/guide/reference/api/admin-indices-flush.html)  
[1] [Elastic — The Search AI Company | Elastic](http://www.elasticsearch.org/guide/reference/api/search/scroll.html)

On Wed, Oct 17, 2012 at 6:19 PM, Amy [amyblarney@gmail.com](mailto:amyblarney@gmail.com) wrote:

> Hi,  
> I'm considering using elasticsearch as my primary db, the alternative being  
> a couchbase-elasticsearch combo.  
> Group discussions appear positive, but I have an issue that I have not seen  
> discussed. If I want to change an index mapping, I need to flush the index.  
> This deletes everything I have stored on Elasticsearch.  
> Is there an alternative?
> 
> --

--

---

<div class="post-metadata">

### Author: ![Amy](https://avatars.discourse-cdn.com/v4/letter/a/4da419/32.png) [@Amy](https://discuss.elastic.co/u/Amy)
#### Post date: [October 18, 2012, 8:14am UTC](https://discuss.elastic.co/t/using-elasticsearch-as-my-primary-database/9395/3 "2012-10-18T08:14:50Z")

</div>

Thank you Radu, that helped. I also found this example of how to reindex in  
Perl: [ElasticSearch.pm v0.36, now with extra sugar | Clinton Gormley [blogs.perl.org]](http://blogs.perl.org/users/clinton_gormley/2011/04/elasticsearchpm-v036-now-with-extra-sugar.html)

On Wednesday, October 17, 2012 5:06:54 PM UTC+1, Radu Gheorghe wrote:

> Hello Amy,
> 
> If you add new fields to your mapping, it should work just fine  
> (they're added to your current mapping). If you try to change the type  
> of a certain field in your mapping, you will get an error, but  
> flushing[0] the index doesn't delete your data.
> 
> If you need to change the type of a field (let's say from long to  
> float), you have to reindex your data. You can do that on the live  
> cluster by scrolling[1] through your data and indexing it in a  
> different type where you have the new mapping.
> 
> Of course if your indices become corrupt for any reason (eg: file  
> system failure), there's no getting away from backups. But that should  
> be the same for any database.
> 
> ## Best regards, Radu
> 
> [http://sematext.com/](http://sematext.com/) -- Elasticsearch -- Solr -- Lucene
> 
> [0]  
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/admin-indices-flush.html)  
> [1] [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/search/scroll.html)
> 
> On Wed, Oct 17, 2012 at 6:19 PM, Amy \<[amybl...@gmail.com](mailto:amybl...@gmail.com) \<javascript:\>\>  
> wrote:
> 
> > Hi,  
> > I'm considering using elasticsearch as my primary db, the alternative  
> > being  
> > a couchbase-elasticsearch combo.  
> > Group discussions appear positive, but I have an issue that I have not  
> > seen  
> > discussed. If I want to change an index mapping, I need to flush the  
> > index.  
> > This deletes everything I have stored on Elasticsearch.  
> > Is there an alternative?
> > 
> > --

--

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [July 6, 2017, 3:08am UTC](https://discuss.elastic.co/t/using-elasticsearch-as-my-primary-database/9395/4 "2017-07-06T03:08:10Z")

</div>


