Skip to content

Instantly share code, notes, and snippets.

@paul-butcher
Last active June 24, 2022 09:33
Show Gist options
  • Select an option

  • Save paul-butcher/a0f46d4a8b3cfc136a12835b4fb15977 to your computer and use it in GitHub Desktop.

Select an option

Save paul-butcher/a0f46d4a8b3cfc136a12835b4fb15977 to your computer and use it in GitHub Desktop.
Delete all open Elasticsearch indices on localhost
curl -XGET localhost:9200/_cat/indices 2>/dev/null | sed 's/.*open //' | sed 's/ .*//'| xargs -I % echo curl -XDELETE localhost:9200/%
@paul-butcher
Copy link
Author

When debugging, or when something has gone awry with test teardown, I end up with a bunch of spare Elasticsearch indices created by test runs, all with unique PID or RNG-based names.

This outputs all the individual requests required to clean them up.

I can then pick and paste the ones I want to delete, while keeping any indices I want to use for comparisons or other local development.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment