Last active
June 24, 2022 09:33
-
-
Save paul-butcher/a0f46d4a8b3cfc136a12835b4fb15977 to your computer and use it in GitHub Desktop.
Delete all open Elasticsearch indices on localhost
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| curl -XGET localhost:9200/_cat/indices 2>/dev/null | sed 's/.*open //' | sed 's/ .*//'| xargs -I % echo curl -XDELETE localhost:9200/% |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.