# Creating/Deleting Index

**URL:** <https://discuss.elastic.co/t/creating-deleting-index/16874>\
**Category:** Elasticsearch\
**Created:** [April 8, 2014, 3:36pm UTC](https://discuss.elastic.co/t/creating-deleting-index/16874 "2014-04-08T15:36:29Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![IronMike](https://avatars.discourse-cdn.com/v4/letter/i/e9a140/32.png) [@IronMike](https://discuss.elastic.co/u/IronMike)\
**Post date:** [April 8, 2014, 3:36pm UTC](https://discuss.elastic.co/t/creating-deleting-index/16874/1 "2014-04-08T15:36:29Z")

</div>

All the examples I have seen so far, check if an index exist, delete it and  
then create the index.  
But in a production environment, isn't the normal to check if the index  
doesn't exist, then create it. But if it does exist, then do nothing,  
because typically the index exists and all we need to do is just index new  
documents?

Am I missing the point?

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/cf6004f5-ef83-4612-8227-e786c2f8b3fc%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/cf6004f5-ef83-4612-8227-e786c2f8b3fc%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![gkwelding](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gkwelding/32/1658_2.png) [@gkwelding](https://discuss.elastic.co/u/gkwelding)\
**Post date:** [April 8, 2014, 3:43pm UTC](https://discuss.elastic.co/t/creating-deleting-index/16874/2 "2014-04-08T15:43:54Z")

</div>

What examples are you referring to?

The only reason I could think of why you'd do this is because the best way  
to deal with bulk deletes and mass mapping changes in Elasticsearch is to  
create a new index and use aliases to point pretty named indices at the  
newly created index before deleting the old one. However, I would always  
create the new index first, switch the alias and only then delete the old  
index.

On Tuesday, April 8, 2014 4:36:29 PM UTC+1, IronMan2014 wrote:

> All the examples I have seen so far, check if an index exist, delete it  
> and then create the index.  
> But in a production environment, isn't the normal to check if the index  
> doesn't exist, then create it. But if it does exist, then do nothing,  
> because typically the index exists and all we need to do is just index new  
> documents?
> 
> Am I missing the point?

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/aa92a79b-3fe5-4346-892c-99ae8c9587d4%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/aa92a79b-3fe5-4346-892c-99ae8c9587d4%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![IronMike](https://avatars.discourse-cdn.com/v4/letter/i/e9a140/32.png) [@IronMike](https://discuss.elastic.co/u/IronMike)\
**Post date:** [April 8, 2014, 3:58pm UTC](https://discuss.elastic.co/t/creating-deleting-index/16874/3 "2014-04-08T15:58:35Z")

</div>

So, lets say I have an index named "godzilla",  
The very first time I run the app, its not there, so I create 'godzilla'  
and index 10 million docs.  
Tomorrow, 1 million docs have changed, and I need to index them due to  
updates, or I have 1 million new docs to index,  
Should the app do nothing in this case, because 'godzilla' already exists,  
and the version of the updated documents will bumped by 1?

On Tuesday, April 8, 2014 11:43:54 AM UTC-4, Garry Welding wrote:

> What examples are you referring to?
> 
> The only reason I could think of why you'd do this is because the best way  
> to deal with bulk deletes and mass mapping changes in Elasticsearch is to  
> create a new index and use aliases to point pretty named indices at the  
> newly created index before deleting the old one. However, I would always  
> create the new index first, switch the alias and only then delete the old  
> index.
> 
> On Tuesday, April 8, 2014 4:36:29 PM UTC+1, IronMan2014 wrote:
> 
> > All the examples I have seen so far, check if an index exist, delete it  
> > and then create the index.  
> > But in a production environment, isn't the normal to check if the index  
> > doesn't exist, then create it. But if it does exist, then do nothing,  
> > because typically the index exists and all we need to do is just index new  
> > documents?
> > 
> > Am I missing the point?

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/f1077f5e-4c03-4aa1-8b2b-ce830812b241%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/f1077f5e-4c03-4aa1-8b2b-ce830812b241%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![gkwelding](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gkwelding/32/1658_2.png) [@gkwelding](https://discuss.elastic.co/u/gkwelding)\
**Post date:** [April 8, 2014, 4:01pm UTC](https://discuss.elastic.co/t/creating-deleting-index/16874/4 "2014-04-08T16:01:23Z")

</div>

If you're just updating/adding then yes, don't delete the index and start  
again. Just let ES deal with versioning the docs.

On Tuesday, April 8, 2014 4:58:35 PM UTC+1, IronMan2014 wrote:

> So, lets say I have an index named "godzilla",  
> The very first time I run the app, its not there, so I create 'godzilla'  
> and index 10 million docs.  
> Tomorrow, 1 million docs have changed, and I need to index them due to  
> updates, or I have 1 million new docs to index,  
> Should the app do nothing in this case, because 'godzilla' already exists,  
> and the version of the updated documents will bumped by 1?
> 
> On Tuesday, April 8, 2014 11:43:54 AM UTC-4, Garry Welding wrote:
> 
> > What examples are you referring to?
> > 
> > The only reason I could think of why you'd do this is because the best  
> > way to deal with bulk deletes and mass mapping changes in Elasticsearch is  
> > to create a new index and use aliases to point pretty named indices at the  
> > newly created index before deleting the old one. However, I would always  
> > create the new index first, switch the alias and only then delete the old  
> > index.
> > 
> > On Tuesday, April 8, 2014 4:36:29 PM UTC+1, IronMan2014 wrote:
> > 
> > > All the examples I have seen so far, check if an index exist, delete it  
> > > and then create the index.  
> > > But in a production environment, isn't the normal to check if the index  
> > > doesn't exist, then create it. But if it does exist, then do nothing,  
> > > because typically the index exists and all we need to do is just index new  
> > > documents?
> > > 
> > > Am I missing the point?

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/722bea1c-2928-4680-8c4a-99d4ca1f9782%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/722bea1c-2928-4680-8c4a-99d4ca1f9782%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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, 1:37am UTC](https://discuss.elastic.co/t/creating-deleting-index/16874/5 "2017-07-06T01:37:32Z")

</div>


