I am extracting the hits from a TopHits aggregation using the Java API:
Map<String, Aggregate> aggregations = searchResponse.aggregations();
TopHitsAggregate topHitsAggregate = searchResponse.aggregations().get("topHits").topHits();
List<Hit<JsonData>> hits = topHitsAggregate.hits().hits();
Using the elasticsearchClient.search(query, MyType.class)
call gives the search hits converted to the target type (MyType in this case) which is really convenient. What is the recommended way to get the TopHits documents converted to the target type instead of the raw JsonData?