I'm making an application that allows users to create reports on customers data, the user is able to add 0 or more grouping fields.
I'm using elastic 2.2.0, so if the user wants to group by day, then by age and then by sex the program sends the following query to elastic:
{
"aggs": {
"group_a": {
"date_histogram": {
"field": "transactionDate",
"interval": "day"
},
"aggs": {
"group_b": {
"terms": {
"field": "age"
}
},
"aggs": {
"group_c": {
"terms": {
"field": "sex"
}
}
}
}
}
}
}
I get this error:
{
"error": {
"root_cause": [
{
"type": "search_parse_exception",
"reason": "Could not find aggregator type [group_c] in [aggs]",
"line": 15,
"col": 11
}
]
}
}
How can I fix this?