Hi All,
I have a requirement like, I need to get the documents count for two fields based on the given ranges. Like, first field having ranges like 0-50,51-100 and second field having ranges like 0-500,501-1000. Now, as we get documents count for each range of first field along with that for each range of first field we need to get documents count for each range of second field.
Below is my sample query.
{ "aggs": { "nested_aggr_noofemp": { "nested": { "path": "numberOfEmployees" }, "aggs": { "noofemp_ranges": { "range": { "field": "numberOfEmployees.value", "ranges": [{ "to": 100 }, { "from": 100, "to": 200 }, { "from": 200 } ] }, "nested_aggr_solvencyRatio": { "nested": { "path": "standardisedViewReferenceCurrency" }, "aggs": { "solvencyRatio_range": { "range": { "field": "standardisedViewReferenceCurrency.derivedFinancialItems.solvencyRatio", "ranges": [{ "to": 50 }, { "from": 51, "to": 100 }, { "from": 101 } ] } } } } } } } } }
But with the above query, I am getting below error msg:
{
"error": {
"root_cause": [
{
"type": "parsing_exception",
"reason": "Found two aggregation type definitions in [noofemp_ranges]: [range] and [nested_aggr_solvencyRatio]",
"line": 23,
"col": 35
}
],
"type": "parsing_exception",
"reason": "Found two aggregation type definitions in [noofemp_ranges]: [range] and [nested_aggr_solvencyRatio]",
"line": 23,
"col": 35
},
"status": 400
}
Please let me know where I did mistake.
Thanks,
Ram Prasad G