I need to query the data using aggregation.My questions I have nested object and I try the query but my question how to do multiple aggregation based on the field which is not in nested object.
Please find the query you may get the idea
GET dealytics2/deal/_search
{
"size": 0,
"_source": {
"includes": [
"master_deal_no",
"advisors.advisor_type"
]
},
"query": {
"bool": {
"must": [
{
"nested": {
"path": "advisors",
"query": {
"bool": {
"should": [
{
"match_phrase": {
"advisors.advisor_type": "Buyer advisors, non-lawyers"
}
},
{
"match_phrase": {
"advisors.advisor_type": "Target_advisors, non-lawyers"
}
}
]
}
}
}
},
{
"range": {
"rank_date": {
"gte": "01/01/2012",
"lte": "31/12/2013",
"format": "dd/MM/yyyy||yyyy"
}
}
}
]
}
},
"aggs": {
"bankers": {
"nested": {
"path": "advisors"
},
"aggs": {
"bankers1": {
"terms": {
"field": "advisors.advisor"
}
}
}
}
}
}