Created
March 13, 2016 23:08
-
-
Save tastywheat/d5ae24b9920147285bc5 to your computer and use it in GitHub Desktop.
elasticsearch aggregation formula
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
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