Skip to content

Instantly share code, notes, and snippets.

@jxstanford
Created June 11, 2015 22:48
Show Gist options
  • Save jxstanford/4b5726b98d102394076b to your computer and use it in GitHub Desktop.
Save jxstanford/4b5726b98d102394076b to your computer and use it in GitHub Desktop.
event type aggregation query
curl -XPOST -d \
'{
"aggs": {
"types": {
"terms": {
"field": "_type"
}
},
"events_by_date": {
"aggs": {
"event_types": {
"terms": {
"field": "_type"
}
}
},
"date_histogram": {
"min_doc_count": 0,
"interval": "1h",
"field": "timestamp",
"extended_bounds" : {
"min" : "2015-05-22T18:36:19.108284+00:00"
}
}
}
},
"query": {
"filtered": {
"query": {
"match_all": {}
},
"filter": {
"bool": {
"must": [
{
"range": {
"timestamp": {
"gte": "2015-02-22T18:36:19.108284+00:00"
}
}
}
]
}
}
}
}
}' \
-H 'Content-Type: application/json' \
http://127.0.0.1:9200/events_*/_search?search_type=count | python -m json.tool
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment