ElasticResponse { public float getMaxScore() { final float maxScore; if (results != null && results.getMaxScore() != null) { maxScore = results.getMaxScore(); } else { maxScore = 0f; } return maxScore; }  ElasticResults getResults(); Map<String,ElasticAggregation> getAggregations(); String getScrollId(); @JsonIgnore List<ElasticHit> getHits(); int getNumHits(); long getTotalNumHits(); float getMaxScore(); @Override String toString();  }
@Test public void testNullMaxScore() throws IOException { ElasticResponse response = mapper.readValue("{\"hits\":{}}", ElasticResponse.class); assertEquals(0, response.getMaxScore(), 1e-9); }
@Test public void testMaxScore() throws IOException { ElasticResponse response = mapper.readValue("{\"hits\":{\"max_score\":0.8}}", ElasticResponse.class); assertEquals(0.8, response.getMaxScore(), 1e-6); }