Skip to content

Instantly share code, notes, and snippets.

@dadoonet
Created May 15, 2013 19:55
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save dadoonet/5586855 to your computer and use it in GitHub Desktop.
Save dadoonet/5586855 to your computer and use it in GitHub Desktop.
Delete By Query usage
echo "clean index"
curl -XDELETE 'http://localhost:9200/twitter?pretty' ; echo
echo "PUT Tweet"
curl -XPUT 'http://localhost:9200/twitter/tweet/1?ttl=1h&pretty' -d '
{
"created_at": "Mon May 13 19:59:27 +0000 2013"
}
' ; echo
# Refresh docs
echo "Refresh index"
curl -XPOST 'http://localhost:9200/twitter/_refresh?pretty' ; echo
echo "Search"
curl -XGET 'http://localhost:9200/twitter/tweet/_search?pretty' -d '
{ "query" : {
"filtered": {
"query": {"match_all": {}},
"filter": {"range": {
"created_at": {
"lt": "now-1h"
}
}}
}
}
}' ; echo
echo "Delete by same query"
curl -XDELETE 'http://localhost:9200/twitter/tweet/_query?pretty' -d '
{
"filtered": {
"query": {"match_all": {}},
"filter": {"range": {
"created_at": {
"lt": "now-1h"
}
}}
}
}' ; echo
# Refresh docs
echo "Refresh index"
curl -XPOST 'http://localhost:9200/twitter/_refresh?pretty' ; echo
echo "Search"
curl -XGET 'http://localhost:9200/twitter/tweet/_search?pretty' -d '
{ "query" : {
"filtered": {
"query": {"match_all": {}},
"filter": {"range": {
"created_at": {
"lt": "now-1h"
}
}}
}
}
}' ; echo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment