# Java API Error on Aggregations

**URL:** <https://discuss.elastic.co/t/java-api-error-on-aggregations/32886>\
**Category:** Elasticsearch\
**Created:** [October 23, 2015, 8:41pm UTC](https://discuss.elastic.co/t/java-api-error-on-aggregations/32886 "2015-10-23T20:41:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![William\_Bowen](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/william_bowen/32/1057_2.png) [@William\_Bowen](https://discuss.elastic.co/u/William_Bowen)\
**Post date:** [October 23, 2015, 8:41pm UTC](https://discuss.elastic.co/t/java-api-error-on-aggregations/32886/1 "2015-10-23T20:41:23Z")

</div>

Hello, I'm using the Java API (1.4.5) to submit JSON like so:

```
SearchResponse response = client.prepareSearch(index).setSource(json).get();

```

Where json is a Map that's being passed to me. Suffice to say, I'm being passed this map and cannot use the builders (without basically deconstructing the map). When I POST the JSON string created from the map to port 9200 in Postman, it comes back fine. However submitting over the transport client through the API I get:

```
org.elasticsearch.ElasticsearchIllegalStateException: show_terms_doc_count_error is false
	at org.elasticsearch.search.aggregations.bucket.terms.InternalTerms$Bucket.getDocCountError(InternalTerms.java:66)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:497)
	at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:654)
	at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:675)
	... 68 more

```

Suffice to say, I've found that it comes down to the aggregations. When I remove them from the JSON, it works. But any of the aggs are causing it. Here's an example:

```
"aggs": {
        "types_count": {
            "terms": {
                "field": "kind",
                "order": {
                    "_term": "asc"
                }
            }
        }
    }

```

Has anyone seen anything like this? I've never seen the issue with simple aggregations and searches yielded no results on the subject.

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![yejinbiao](https://avatars.discourse-cdn.com/v4/letter/y/eb9ed0/32.png) [@yejinbiao](https://discuss.elastic.co/u/yejinbiao)\
**Post date:** [January 17, 2017, 2:26am UTC](https://discuss.elastic.co/t/java-api-error-on-aggregations/32886/2 "2017-01-17T02:26:49Z")

</div>

i met the problem too,have you ever found a way to solve it ?

---

<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 5, 2017, 10:04pm UTC](https://discuss.elastic.co/t/java-api-error-on-aggregations/32886/3 "2017-07-05T22:04:07Z")

</div>


