# Elasticsearch 7.4.1 java stats\_buckets

**URL:** <https://discuss.elastic.co/t/elasticsearch-7-4-1-java-stats-buckets/277055>\
**Category:** Elasticsearch\
**Created:** [June 25, 2021, 11:47am UTC](https://discuss.elastic.co/t/elasticsearch-7-4-1-java-stats-buckets/277055 "2021-06-25T11:47:21Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jey](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jey/32/90832_2.png) [@jey](https://discuss.elastic.co/u/jey)\
**Post date:** [June 25, 2021, 11:47am UTC](https://discuss.elastic.co/t/elasticsearch-7-4-1-java-stats-buckets/277055/1 "2021-06-25T11:47:21Z")

</div>

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

```auto
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();

```

```auto
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
}'

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 23, 2021, 11:48am UTC](https://discuss.elastic.co/t/elasticsearch-7-4-1-java-stats-buckets/277055/2 "2021-07-23T11:48:05Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
