.startObject("location").field("lat", 40.65).field("lon", -73.95).endObject() // to NY: 8.572 km
.endObject()
.endArray()
.endObject()));
SearchResponse searchResponse = client().prepareSearch("companies").setQuery(matchAllQuery())
<BUG>.addSort(SortBuilders.geoDistanceSort("branches.location").point(40.7143528, -74.0059731).order(SortOrder.ASC))
</BUG>
.execute().actionGet();
assertHitCount(searchResponse, 4);
assertOrderedSearchHits(searchResponse, "1", "2", "3", "4");

.startObject("location").field("lat", 40.65).field("lon", -73.95).endObject() // to NY: 8.572 km
.endObject()
.endArray()
.endObject()));
SearchResponse searchResponse = client().prepareSearch("companies").setQuery(matchAllQuery())
.addSort(SortBuilders.geoDistanceSort("branches.location").point(40.7143528, -74.0059731).order(SortOrder.ASC).setNestedPath("branches"))
.execute().actionGet();
assertHitCount(searchResponse, 4);
assertOrderedSearchHits(searchResponse, "1", "2", "3", "4");
