# Delete and recreate index in elasticsearch

**URL:** <https://discuss.elastic.co/t/delete-and-recreate-index-in-elasticsearch/292651>\
**Category:** Logstash\
**Created:** [December 22, 2021, 8:33am UTC](https://discuss.elastic.co/t/delete-and-recreate-index-in-elasticsearch/292651 "2021-12-22T08:33:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vikrant1](https://avatars.discourse-cdn.com/v4/letter/v/dbc845/32.png) [@Vikrant1](https://discuss.elastic.co/u/Vikrant1)\
**Post date:** [December 22, 2021, 8:33am UTC](https://discuss.elastic.co/t/delete-and-recreate-index-in-elasticsearch/292651/1 "2021-12-22T08:33:24Z")

</div>

Hi All,

Thanks for taking your time to read this query -

I have to delete the existing index and the need to create same Index in Elasticsearch using the logstash config file before data loading start (reading from oracle) as input

we are doing to implement truncate and load type of index

so could you please share code for it using logstash

---

<div class="post-metadata">

**Author:** ![AquaX](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aquax/32/92006_2.png) [@AquaX](https://discuss.elastic.co/u/AquaX)\
**Post date:** [December 22, 2021, 2:17pm UTC](https://discuss.elastic.co/t/delete-and-recreate-index-in-elasticsearch/292651/2 "2021-12-22T14:17:51Z")

</div>

If you delete an index and logstash tries to write to an index that does not exist a new index will automatically be created.  
You can also delete an index and then recreate it using an index template on Elasticsearch before you start sending data to it.

---

<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:** [January 19, 2022, 2:18pm UTC](https://discuss.elastic.co/t/delete-and-recreate-index-in-elasticsearch/292651/3 "2022-01-19T14:18:51Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
