# Recommended way to delete an index

**URL:** <https://discuss.elastic.co/t/recommended-way-to-delete-an-index/90769>\
**Category:** Elasticsearch\
**Created:** [June 25, 2017, 8:38pm UTC](https://discuss.elastic.co/t/recommended-way-to-delete-an-index/90769 "2017-06-25T20:38:21Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![animageofmine](https://avatars.discourse-cdn.com/v4/letter/a/7feea3/32.png) [@animageofmine](https://discuss.elastic.co/u/animageofmine)\
**Post date:** [June 25, 2017, 8:38pm UTC](https://discuss.elastic.co/t/recommended-way-to-delete-an-index/90769/1 "2017-06-25T20:38:21Z")

</div>

If you delete the index using DELETE API, does it clear the fielddata / cache? Or is it suggested that we stop the index before deleting it?

I want to make sure that we don't keep increasing memory footprint (JVM/ OS Memory) forever. Thanks so much.

---

<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:** [June 25, 2017, 11:27pm UTC](https://discuss.elastic.co/t/recommended-way-to-delete-an-index/90769/2 "2017-06-25T23:27:03Z")

</div>

If you delete the index you delete anything else related to it, including any caches.

---

<div class="post-metadata">

**Author:** ![animageofmine](https://avatars.discourse-cdn.com/v4/letter/a/7feea3/32.png) [@animageofmine](https://discuss.elastic.co/u/animageofmine)\
**Post date:** [June 25, 2017, 11:28pm UTC](https://discuss.elastic.co/t/recommended-way-to-delete-an-index/90769/3 "2017-06-25T23:28:22Z")

</div>

Thanks for the confirmation.

If you close the index, does it get rid of all resources that it would consume other than the disk space?

---

<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:** [June 25, 2017, 11:28pm UTC](https://discuss.elastic.co/t/recommended-way-to-delete-an-index/90769/4 "2017-06-25T23:28:50Z")

</div>

What do you mean by stop the index?

---

<div class="post-metadata">

**Author:** ![animageofmine](https://avatars.discourse-cdn.com/v4/letter/a/7feea3/32.png) [@animageofmine](https://discuss.elastic.co/u/animageofmine)\
**Post date:** [June 25, 2017, 11:30pm UTC](https://discuss.elastic.co/t/recommended-way-to-delete-an-index/90769/5 "2017-06-25T23:30:10Z")

</div>

My bad, I meant close the index. [https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-open-close.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-open-close.html)

---

<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:** [June 25, 2017, 11:34pm UTC](https://discuss.elastic.co/t/recommended-way-to-delete-an-index/90769/6 "2017-06-25T23:34:19Z")

</div>

If you close an index it removes any caches, it still takes some resources because the cluster maintains the index info in cluster state (in memory).

---

<div class="post-metadata">

**Author:** ![animageofmine](https://avatars.discourse-cdn.com/v4/letter/a/7feea3/32.png) [@animageofmine](https://discuss.elastic.co/u/animageofmine)\
**Post date:** [June 25, 2017, 11:37pm UTC](https://discuss.elastic.co/t/recommended-way-to-delete-an-index/90769/7 "2017-06-25T23:37:04Z")

</div>

I am guessing that is purely metadata like mentioned in the documentation and doesn't occupy too much space. We have observed that having too many indices/shards slows down the cluster and there isn't any easy way to recovery from that state. For example, we have 47k shards on a cluster of 8 nodes (5 data + 3 dedicated master nodes).

We also have dedicated master nodes (3 to be specific), so suppose the that master nodes take care keeping index information.

---

<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:** [June 26, 2017, 1:26am UTC](https://discuss.elastic.co/t/recommended-way-to-delete-an-index/90769/8 "2017-06-26T01:26:37Z")

</div>

Each shard needs a certain amount of resources to exist.

> [@animageofmine](#):
>
> 47k shards on a cluster of 8 nodes (5 data + 3 dedicated master nodes)

Yeah, that's a little overboard.

What version are you on.

---

<div class="post-metadata">

**Author:** ![animageofmine](https://avatars.discourse-cdn.com/v4/letter/a/7feea3/32.png) [@animageofmine](https://discuss.elastic.co/u/animageofmine)\
**Post date:** [June 26, 2017, 1:32am UTC](https://discuss.elastic.co/t/recommended-way-to-delete-an-index/90769/9 "2017-06-26T01:32:57Z")

</div>

version 5.3

---

<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:** [June 26, 2017, 5:43am UTC](https://discuss.elastic.co/t/recommended-way-to-delete-an-index/90769/10 "2017-06-26T05:43:27Z")

</div>

Use the `_shrink` API to reduce the count for old indices.

---

<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:** [July 17, 2017, 9:11pm UTC](https://discuss.elastic.co/t/recommended-way-to-delete-an-index/90769/11 "2017-07-17T21:11:43Z")

</div>

A quick question @animageofmine, are you using the default number of shards or have you customised them?

---

<div class="post-metadata">

**Author:** ![animageofmine](https://avatars.discourse-cdn.com/v4/letter/a/7feea3/32.png) [@animageofmine](https://discuss.elastic.co/u/animageofmine)\
**Post date:** [July 17, 2017, 11:52pm UTC](https://discuss.elastic.co/t/recommended-way-to-delete-an-index/90769/12 "2017-07-17T23:52:08Z")

</div>

customized. It is based on the number of expected documents for index. Why do you ask?

---

<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:** [July 17, 2017, 11:58pm UTC](https://discuss.elastic.co/t/recommended-way-to-delete-an-index/90769/13 "2017-07-17T23:58:28Z")

</div>

Just wondering if you were using defaults or not 🙂

---

<div class="post-metadata">

**Author:** ![animageofmine](https://avatars.discourse-cdn.com/v4/letter/a/7feea3/32.png) [@animageofmine](https://discuss.elastic.co/u/animageofmine)\
**Post date:** [July 18, 2017, 12:37am UTC](https://discuss.elastic.co/t/recommended-way-to-delete-an-index/90769/14 "2017-07-18T00:37:34Z")

</div>

ok :-). Default is way to high for most of the cases for our system.

If you get a chance to look at this question, I would really appreciate that.

> [@Does transport client cache nodes in the cluster?](https://discuss.elastic.co/t/does-transport-client-cache-nodes-in-the-cluster/93243):
>
> We use transport client (elastic4s) to communicate with ES cluster via consul. One of the problems we have seen so far is that the client keeps sending queries to the dead nodes. For example, if the data node node1 is dockerized and if you stop the process inside the container (for testing purpose), but the container is still on, consul does not redirect the queries to that node. However, we still see the queries routed to the dead node node1. I know the client is cluster aware, but I am not s…

---

<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:** [August 15, 2017, 12:38am UTC](https://discuss.elastic.co/t/recommended-way-to-delete-an-index/90769/15 "2017-08-15T00:38:04Z")

</div>

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