Skip to content

Instantly share code, notes, and snippets.

@tastywheat
Created March 13, 2016 23:08
Show Gist options
  • Save tastywheat/d5ae24b9920147285bc5 to your computer and use it in GitHub Desktop.
Save tastywheat/d5ae24b9920147285bc5 to your computer and use it in GitHub Desktop.
elasticsearch aggregation formula
{
query: {
filter: {...}
}
aggs: {
impressions: {...},
gender: {
filters: {
filters: {
M: {...},
F: {...},
unknown: {...}
}
},
aggs: {
impressions: {...},
age: {...}
}
}
}
}
agg(name, bucketFilter, metrics, subAgg)
function agg (name, bucketFilter, metrics, subAgg) {
return {
[name]: {
...bucketFilter,
aggs: {
...metrics,
...subAgg
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment