Skip to content

Instantly share code, notes, and snippets.

@jworl
Last active September 7, 2017 19:13
Show Gist options
  • Save jworl/f5ff917ab98abf7d00c106da1bd7c291 to your computer and use it in GitHub Desktop.
Save jworl/f5ff917ab98abf7d00c106da1bd7c291 to your computer and use it in GitHub Desktop.
elasticsearch delete by query
ES_DELETE_QUERY(){
INDEX=$1
KEY=$2
VALUE=$3
curl -XPOST 'localhost:9200/${INDEX}/_delete_by_query?scroll_size=5000&pretty' -H 'Content-Type: application/json' -d'
{
"query": {
"match": {
"${KEY}": "${VALUE}"
}
}
}
'
}
ES_DELETE_REGEX(){
INDEX=$1
KEY=$2
REGEX=$3
curl -XPOST 'localhost:9200/${INDEX}/_delete_by_query?scroll_size=5000&pretty' -H 'Content-Type: application/json' -d'
{
"query": {
"regexp":{
"${KEY}": "${REGEX}"
}
}
}
'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment