# Deleting ElasticSearch Data Directory

**URL:** <https://discuss.elastic.co/t/deleting-elasticsearch-data-directory/265820>\
**Category:** Elasticsearch\
**Created:** [March 1, 2021, 2:39pm UTC](https://discuss.elastic.co/t/deleting-elasticsearch-data-directory/265820 "2021-03-01T14:39:27Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andrew\_Tillotson](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/andrew_tillotson/32/78503_2.png) [@Andrew\_Tillotson](https://discuss.elastic.co/u/Andrew_Tillotson)\
**Post date:** [March 1, 2021, 2:39pm UTC](https://discuss.elastic.co/t/deleting-elasticsearch-data-directory/265820/1 "2021-03-01T14:39:27Z")

</div>

If I just delete the directory in which the data is stored, restart Elasticsearch, it should recreate that directory and populate it with new data according to the config, correct?

I have unassigned shards, but would just like to start from scratch. Is this the best way to do it?

---

<div class="post-metadata">

**Author:** ![Eduardo\_Iglesias](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eduardo_iglesias/32/78395_2.png) [@Eduardo\_Iglesias](https://discuss.elastic.co/u/Eduardo_Iglesias)\
**Post date:** [March 1, 2021, 3:24pm UTC](https://discuss.elastic.co/t/deleting-elasticsearch-data-directory/265820/2 "2021-03-01T15:24:45Z")

</div>

> [@Andrew\_Tillotson](#):
>
> s

Hello @Andrew_Tillotson if what you're trying to do is just to sort out the unassigned shards deleting the data directory and start from scratch is not the best option at all.

First check in which of your nodes are the unassigned shards:

`GET _cat/shards/your_index`  
`GET _cat/allocation/explain`

This two requets will output where you unassigned shards are and the reason why they remain like that.

---

<div class="post-metadata">

**Author:** ![Andrew\_Tillotson](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/andrew_tillotson/32/78503_2.png) [@Andrew\_Tillotson](https://discuss.elastic.co/u/Andrew_Tillotson)\
**Post date:** [March 1, 2021, 3:30pm UTC](https://discuss.elastic.co/t/deleting-elasticsearch-data-directory/265820/3 "2021-03-01T15:30:27Z")

</div>

I understand its not the best option, but the data in the system isn't what we'll be using - just test stuff.

I just wanted to make sure I wasn't creating a bigger headache by deleting the directory and letting it rebuild.

---

<div class="post-metadata">

**Author:** ![Eduardo\_Iglesias](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eduardo_iglesias/32/78395_2.png) [@Eduardo\_Iglesias](https://discuss.elastic.co/u/Eduardo_Iglesias)\
**Post date:** [March 1, 2021, 3:42pm UTC](https://discuss.elastic.co/t/deleting-elasticsearch-data-directory/265820/4 "2021-03-01T15:42:11Z")

</div>

@Andrew_Tillotson If you proceed your cluster will be empty. Indices, templates, visualization/dashboards, user/roles, machine learning jobs, etcetera will be all gone.

---

<div class="post-metadata">

**Author:** ![Andrew\_Tillotson](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/andrew_tillotson/32/78503_2.png) [@Andrew\_Tillotson](https://discuss.elastic.co/u/Andrew_Tillotson)\
**Post date:** [March 1, 2021, 3:55pm UTC](https://discuss.elastic.co/t/deleting-elasticsearch-data-directory/265820/5 "2021-03-01T15:55:29Z")

</div>

well I don't want to lose all of that.. I'll check out the shards. I can delete specific unallocated shards and not lose the rest, correct?

Thanks again for the help.

---

<div class="post-metadata">

**Author:** ![Eduardo\_Iglesias](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eduardo_iglesias/32/78395_2.png) [@Eduardo\_Iglesias](https://discuss.elastic.co/u/Eduardo_Iglesias)\
**Post date:** [March 1, 2021, 4:10pm UTC](https://discuss.elastic.co/t/deleting-elasticsearch-data-directory/265820/6 "2021-03-01T16:10:37Z")

</div>

Not sure about how to delete unassigned shards, can you share your index settings and the output of the previously 2 requests?

You can update the index settings for proper allocation, this usually solves the problem.

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [March 2, 2021, 3:04am UTC](https://discuss.elastic.co/t/deleting-elasticsearch-data-directory/265820/7 "2021-03-02T03:04:16Z")

</div>

Welcome to our community! 😃

Please don't do this, it's not supported and likely will cause Elasticsearch to break.  
Make sure you always use the APIs to delete data.

---

<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:** [March 30, 2021, 3:05am UTC](https://discuss.elastic.co/t/deleting-elasticsearch-data-directory/265820/8 "2021-03-30T03:05:06Z")

</div>

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