# TopHits aggregation in Java: tophits is always null in parsing response

**URL:** <https://discuss.elastic.co/t/tophits-aggregation-in-java-tophits-is-always-null-in-parsing-response/27594>\
**Category:** Elasticsearch\
**Created:** [August 18, 2015, 2:51pm UTC](https://discuss.elastic.co/t/tophits-aggregation-in-java-tophits-is-always-null-in-parsing-response/27594 "2015-08-18T14:51:28Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![drjz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/drjz/32/972_2.png) [@drjz](https://discuss.elastic.co/u/drjz)\
**Post date:** [August 18, 2015, 2:51pm UTC](https://discuss.elastic.co/t/tophits-aggregation-in-java-tophits-is-always-null-in-parsing-response/27594/1 "2015-08-18T14:51:28Z")

</div>

_Update:_ the error was on my side, please ignore. My apologies.

I have exactly copied the code here: [https://www.elastic.co/guide/en/elasticsearch/client/java-api/current/\_metrics\_aggregations.html#java-aggs-metrics-tophits](https://www.elastic.co/guide/en/elasticsearch/client/java-api/current/_metrics_aggregations.html#java-aggs-metrics-tophits)

When I try to get the Top Hits in "top", I get an empty TopHits objects. When I print out the response, I see the "top" as part of the JSON and it consists of hits. Is the documentation here still up to date? What can cause the top hits response parsing in Java getting null?

---

<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, 11:55pm UTC](https://discuss.elastic.co/t/tophits-aggregation-in-java-tophits-is-always-null-in-parsing-response/27594/2 "2017-07-05T23:55:15Z")

</div>


