assertThat(((Number) searchResponse.getHits().getAt(2).sortValues()[0]).doubleValue(), closeTo(2874.0d, 10d));
assertThat(((Number) searchResponse.getHits().getAt(3).sortValues()[0]).doubleValue(), closeTo(5301.0d, 10d));
searchResponse = client().prepareSearch("companies").setQuery(matchAllQuery())
.addSort(
SortBuilders.geoDistanceSort("branches.location").setNestedPath("branches")
<BUG>.point(40.7143528, -74.0059731).sortMode("avg").order(SortOrder.DESC)
</BUG>
)
.execute().actionGet();
assertHitCount(searchResponse, 4);

assertThat(((Number) searchResponse.getHits().getAt(2).sortValues()[0]).doubleValue(), closeTo(2874.0d, 10d));
assertThat(((Number) searchResponse.getHits().getAt(3).sortValues()[0]).doubleValue(), closeTo(5301.0d, 10d));
searchResponse = client().prepareSearch("companies").setQuery(matchAllQuery())
.addSort(
SortBuilders.geoDistanceSort("branches.location").setNestedPath("branches")
.point(40.7143528, -74.0059731).sortMode("avg").order(SortOrder.DESC).setNestedPath("branches")
)
.execute().actionGet();
assertHitCount(searchResponse, 4);
