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


(Laurent Jakubina) #1

Hello everyone,

Simple question: with Curator (the singleton CLI: 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.


(Aaron Mildenstein) #2

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:

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

This will match myindexname exactly, and nothing else.


(Laurent Jakubina) #3

Thank you very much, Mr. Curator :slight_smile:

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 !


(Aaron Mildenstein) #4

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

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

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

This might allow you to do:

delete_index ${index_name}

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


(Laurent Jakubina) #5

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

Thank you very much for the detailed answer !


(system) closed #6

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