ElasticResponse { public long getTotalNumHits() { final long total; if (results != null && results.getTotal() != null) { total = results.getTotal(); } else { total = 0L; } return total; }  ElasticResults getResults(); Map<String,ElasticAggregation> getAggregations(); String getScrollId(); @JsonIgnore List<ElasticHit> getHits(); int getNumHits(); long getTotalNumHits(); float getMaxScore(); @Override String toString();  }
@Test public void testTotalHits() throws IOException { ElasticResponse response = mapper.readValue("{\"hits\":{\"total\":10}}", ElasticResponse.class); assertEquals(10, response.getTotalNumHits()); }