I made an elasticsearch request in json with aggregation and stats_buckets.
I have an error:
org.elasticsearch.action.ActionRequestValidationException: Validation Failed: 1: No aggregation found for path [terms_caller_number._count]
curl request works but not java request.
I use Elasticsearch 7.4.1
How to do ? Thank you
this.elastic
.prepareSearch("doc")
.setQuery(query)
.addAggregation(AggregationBuilders
.terms("terms_caller_number")
.field("caller_number.keyword")
.subAggregation(PipelineAggregatorBuilders.statsBucket("total_sum", "terms_caller_number._count"))
)
.setSize(0)
.execute()
.actionGet();
curl -s -XGET 'http://localhost:9200/doc/_search?pretty' -H 'Content-Type: application/json' -d '{
"query": {
"bool": {
"must": [
{
"range" : {
"date" : {
"gte": "2021-06-01 00:00",
"lt": "2021-06-30 00:00",
"format": "yyyy-MM-dd HH:mm"
}
}
}
]
}
},
"aggs": {
"caller_number": {
"terms": {
"field": "terms_caller_number.keyword"
}
},
"total_sum": {
"stats_bucket": {
"buckets_path": "terms_caller_number._count"
}
}
},
"size": 0
}'