Skip to content

Instantly share code, notes, and snippets.

@sebastialonso
Last active March 13, 2018 21:10
Show Gist options
  • Save sebastialonso/b8958417d62fa94b24d215fdcae1a72c to your computer and use it in GitHub Desktop.
Save sebastialonso/b8958417d62fa94b24d215fdcae1a72c to your computer and use it in GitHub Desktop.
Aggregation in Elastic
curl -X POST -H 'Content-Type: application/json' http://localhost:9200/data-obj/data-obj/_search?size=0&pretty -d '
{
"aggs": {
"range_agg": {
"range": {
"field": "age",
"ranges": [
{"to": 20},
{"from": 20, "to": 25},
{"from": 25, "to": 30},
{"from": 30}
]
},
"aggs": {
"job": {
"terms": {"field": "job"},
"aggs": {
"damage": {
"terms": {"field": "damage"},
"aggs": {
"iv": {
"avg": {"field": "iv"}
},
"blood": {
"avg": {"field": "blood"}
}
}
}
}
}
}
}
}
}
'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment