Skip to content

Instantly share code, notes, and snippets.

@sebastialonso
Created March 13, 2018 21:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sebastialonso/b82cc8aa79e9d3139eaf22b8ca983567 to your computer and use it in GitHub Desktop.
Save sebastialonso/b82cc8aa79e9d3139eaf22b8ca983567 to your computer and use it in GitHub Desktop.
Nested aggregation
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": {
"nested_diagnostic_flavour": {
"nested": {
"path": "diagnostics"
},
"aggs": {
"flavour": {
"terms": { "field": "diagnostics.flavour"},
"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