# ElasticSearch curator CLI: how to delete an index by name?

**URL:** https://discuss.elastic.co/t/elasticsearch-curator-cli-how-to-delete-an-index-by-name/172858
**Category:** Elasticsearch
**Created:** [March 18, 2019, 7:51pm UTC](https://discuss.elastic.co/t/elasticsearch-curator-cli-how-to-delete-an-index-by-name/172858 "2019-03-18T19:51:04Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![ljak](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ljak/32/40307_2.png) [@ljak](https://discuss.elastic.co/u/ljak)
#### Post date: [March 18, 2019, 7:51pm UTC](https://discuss.elastic.co/t/elasticsearch-curator-cli-how-to-delete-an-index-by-name/172858/1 "2019-03-18T19:51:04Z")

</div>

Hello everyone,

Simple question: with Curator (the singleton CLI: [https://www.elastic.co/guide/en/elasticsearch/client/curator/current/singleton-cli.html](https://www.elastic.co/guide/en/elasticsearch/client/curator/current/singleton-cli.html)), I'm interesting on deleting an index by using just the name. I understand that I need to use a JSON object to "filter" indices I wish to delete... but that does not seem available or did I miss something ?

Thanks a lot.

---

<div class="post-metadata">

### Author: ![theuntergeek](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/theuntergeek/32/44961_2.png) [@theuntergeek](https://discuss.elastic.co/u/theuntergeek)
#### Post date: [March 18, 2019, 8:16pm UTC](https://discuss.elastic.co/t/elasticsearch-curator-cli-how-to-delete-an-index-by-name/172858/2 "2019-03-18T20:16:58Z")

</div>

I'm going to put the filter in regular YAML format to give you an idea of what it looks like in the regular config file. Then a (hopefully) valid JSON version:

```auto
filtertype: pattern
kind: regex
value: '^myindexname$'

```

```auto
curator_cli ... --filterlist "{\"filtertype\":\"pattern\",\"kind\":\"regex\",\"value\":\"'^myindexname$'\"}"

```

This will match `myindexname` _exactly,_ and nothing else.

---

<div class="post-metadata">

### Author: ![ljak](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ljak/32/40307_2.png) [@ljak](https://discuss.elastic.co/u/ljak)
#### Post date: [March 18, 2019, 8:37pm UTC](https://discuss.elastic.co/t/elasticsearch-curator-cli-how-to-delete-an-index-by-name/172858/3 "2019-03-18T20:37:45Z")

</div>

Thank you very much, Mr. Curator 🙂

Questions though:

- is `myindexname` a variable available somehow ? And is it mentioned into the docs ?
- could it be a nice feature to be able to delete indices without the JSON, like  
`curator_cli delete_indices ${indice_name}` (${indice\_name} is easily got by doing `curator_cli show_indices`).

Thanks again !

---

<div class="post-metadata">

### Author: ![theuntergeek](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/theuntergeek/32/44961_2.png) [@theuntergeek](https://discuss.elastic.co/u/theuntergeek)
#### Post date: [March 18, 2019, 8:59pm UTC](https://discuss.elastic.co/t/elasticsearch-curator-cli-how-to-delete-an-index-by-name/172858/4 "2019-03-18T20:59:41Z")

</div>

> [@ljak](#):
>
> is `myindexname` a variable available somehow ?

No. It was arbitrary. If your index was named "`prod-logs`", then you would have `value: '^prod-logs$'`.

> [@ljak](#):
>
> could it be a nice feature to be able to delete indices without the JSON, like  
> `curator_cli delete_indices ${indice_name}` (${indice\_name} is easily got by doing `curator_cli show_indices` ).

Because of how parsing works, this change will not be made to the curator code. However:

```auto
alias delete_index=$(_delete_index() { curator_cli ARGS --filterlist "{\"filtertype\":\"pattern\",\"kind\":\"regex\",\"value\":\"'^${1}'\"}" ;}; _delete_index)

```

This _might_ allow you to do:

```auto
delete_index ${index_name}

```

I haven't tested it, but it should be possible.

---

<div class="post-metadata">

### Author: ![ljak](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ljak/32/40307_2.png) [@ljak](https://discuss.elastic.co/u/ljak)
#### Post date: [March 18, 2019, 9:03pm UTC](https://discuss.elastic.co/t/elasticsearch-curator-cli-how-to-delete-an-index-by-name/172858/5 "2019-03-18T21:03:44Z")

</div>

I see and yes, I'm working on that (the alias) !

Thank you very much for the detailed answer !

---

<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: [April 15, 2019, 9:03pm UTC](https://discuss.elastic.co/t/elasticsearch-curator-cli-how-to-delete-an-index-by-name/172858/6 "2019-04-15T21:03:53Z")

</div>

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