Created
January 25, 2018 20:19
-
-
Save dnault/2b6d4c8b675868e00ad5f8b159348e3b to your computer and use it in GitHub Desktop.
Delete all documents from an Elasticsearch index
This file contains 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
#!/bin/sh | |
INDEX=$1 | |
# optionally limit the deletion to a specific type | |
TYPE=$2 | |
BASE_URL=http://localhost:9200 | |
if [ "$#" -eq 1 ]; then | |
URI_PATH=$1 | |
elif [ "$#" -eq 2 ]; then | |
URI_PATH=$1/$2 | |
else | |
echo "USAGE: es-clear.sh <index> [type]" | |
exit 1 | |
fi | |
curl -XPOST http://localhost:9200/$URI_PATH/_delete_by_query -d '{ | |
"query": { | |
"match_all": {} | |
} | |
}' | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment