issue related to aggregation
swetarai763 opened this issue · comments
swetarai763 commented
i need to understand this clause which is written by using bodybuilder
body.aggregation('terms', underfined, 'terms', elasticAggregationHelper.termOptions('type','_count'));
I am not able to understand this termOptions and not able to find it on bodybuilder site
could you please guide me @danpaz
Thanks
swetarai763 commented
Hi
I have go through to this doc but not able to understand the last clause
i.e termOptions
Could you please guide.
Thanks,
sweta
…On Wed, Jul 24, 2019, 7:02 PM Ferron H ***@***.***> wrote:
https://bodybuilder.js.org/docs/#aggregation
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#232?email_source=notifications&email_token=AMWCUDYTG5X765Y3OK2A6TTQBBKWBA5CNFSM4IGNSF6KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD2WK5CA#issuecomment-514633352>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AMWCUDZLNCMEDSYD3XITEA3QBBKWBANCNFSM4IGNSF6A>
.
Ferron H commented
The last parameter is for nested aggregation (agg with-in an agg /sub agg).
A simple example would be this. Let's say I'm generating an aggregation for tags, but with-in that aggregation I want to aggregation the publishers of those tags.
You can think of it as a sub-query
I'd do something like this :
bodybuilder()
.aggregation('terms', 'tags.keyword', { size: 10 }, 'top-tags', (a1) => {
return a1.aggregation('terms', 'publishers.keyword', { size: 10 }, 'top-publishers')
}).build()
{
"aggs": {
"top-tags": {
"terms": {
"field": "tags.keyword",
"size": 10
},
"aggs": {
"top-publishers": {
"terms": {
"field": "publishers.keyword",
"size": 10
}
}
}
}
}
}