|
@@ -551,7 +551,7 @@ public class GeoDistanceIT extends ESIntegTestCase {
|
|
|
|
|
|
// Order: Asc
|
|
|
SearchResponse searchResponse = client().prepareSearch("companies").setQuery(matchAllQuery())
|
|
|
- .addSort(SortBuilders.geoDistanceSort("branches.location").point(40.7143528, -74.0059731).order(SortOrder.ASC))
|
|
|
+ .addSort(SortBuilders.geoDistanceSort("branches.location").point(40.7143528, -74.0059731).order(SortOrder.ASC).setNestedPath("branches"))
|
|
|
.execute().actionGet();
|
|
|
|
|
|
assertHitCount(searchResponse, 4);
|
|
@@ -563,7 +563,7 @@ public class GeoDistanceIT extends ESIntegTestCase {
|
|
|
|
|
|
// Order: Asc, Mode: max
|
|
|
searchResponse = client().prepareSearch("companies").setQuery(matchAllQuery())
|
|
|
- .addSort(SortBuilders.geoDistanceSort("branches.location").point(40.7143528, -74.0059731).order(SortOrder.ASC).sortMode("max"))
|
|
|
+ .addSort(SortBuilders.geoDistanceSort("branches.location").point(40.7143528, -74.0059731).order(SortOrder.ASC).sortMode("max").setNestedPath("branches"))
|
|
|
.execute().actionGet();
|
|
|
|
|
|
assertHitCount(searchResponse, 4);
|
|
@@ -575,7 +575,7 @@ public class GeoDistanceIT extends ESIntegTestCase {
|
|
|
|
|
|
// Order: Desc
|
|
|
searchResponse = client().prepareSearch("companies").setQuery(matchAllQuery())
|
|
|
- .addSort(SortBuilders.geoDistanceSort("branches.location").point(40.7143528, -74.0059731).order(SortOrder.DESC))
|
|
|
+ .addSort(SortBuilders.geoDistanceSort("branches.location").point(40.7143528, -74.0059731).order(SortOrder.DESC).setNestedPath("branches"))
|
|
|
.execute().actionGet();
|
|
|
|
|
|
assertHitCount(searchResponse, 4);
|
|
@@ -587,7 +587,7 @@ public class GeoDistanceIT extends ESIntegTestCase {
|
|
|
|
|
|
// Order: Desc, Mode: min
|
|
|
searchResponse = client().prepareSearch("companies").setQuery(matchAllQuery())
|
|
|
- .addSort(SortBuilders.geoDistanceSort("branches.location").point(40.7143528, -74.0059731).order(SortOrder.DESC).sortMode("min"))
|
|
|
+ .addSort(SortBuilders.geoDistanceSort("branches.location").point(40.7143528, -74.0059731).order(SortOrder.DESC).sortMode("min").setNestedPath("branches"))
|
|
|
.execute().actionGet();
|
|
|
|
|
|
assertHitCount(searchResponse, 4);
|
|
@@ -598,7 +598,7 @@ public class GeoDistanceIT extends ESIntegTestCase {
|
|
|
assertThat(((Number) searchResponse.getHits().getAt(3).sortValues()[0]).doubleValue(), closeTo(0d, 10d));
|
|
|
|
|
|
searchResponse = client().prepareSearch("companies").setQuery(matchAllQuery())
|
|
|
- .addSort(SortBuilders.geoDistanceSort("branches.location").point(40.7143528, -74.0059731).sortMode("avg").order(SortOrder.ASC))
|
|
|
+ .addSort(SortBuilders.geoDistanceSort("branches.location").point(40.7143528, -74.0059731).sortMode("avg").order(SortOrder.ASC).setNestedPath("branches"))
|
|
|
.execute().actionGet();
|
|
|
|
|
|
assertHitCount(searchResponse, 4);
|
|
@@ -611,7 +611,7 @@ public class GeoDistanceIT extends ESIntegTestCase {
|
|
|
searchResponse = client().prepareSearch("companies").setQuery(matchAllQuery())
|
|
|
.addSort(
|
|
|
SortBuilders.geoDistanceSort("branches.location").setNestedPath("branches")
|
|
|
- .point(40.7143528, -74.0059731).sortMode("avg").order(SortOrder.DESC)
|
|
|
+ .point(40.7143528, -74.0059731).sortMode("avg").order(SortOrder.DESC).setNestedPath("branches")
|
|
|
)
|
|
|
.execute().actionGet();
|
|
|
|
|
@@ -625,7 +625,7 @@ public class GeoDistanceIT extends ESIntegTestCase {
|
|
|
searchResponse = client().prepareSearch("companies").setQuery(matchAllQuery())
|
|
|
.addSort(
|
|
|
SortBuilders.geoDistanceSort("branches.location").setNestedFilter(termQuery("branches.name", "brooklyn"))
|
|
|
- .point(40.7143528, -74.0059731).sortMode("avg").order(SortOrder.ASC)
|
|
|
+ .point(40.7143528, -74.0059731).sortMode("avg").order(SortOrder.ASC).setNestedPath("branches")
|
|
|
)
|
|
|
.execute().actionGet();
|
|
|
assertHitCount(searchResponse, 4);
|
|
@@ -637,7 +637,7 @@ public class GeoDistanceIT extends ESIntegTestCase {
|
|
|
assertThat(((Number) searchResponse.getHits().getAt(3).sortValues()[0]).doubleValue(), equalTo(Double.MAX_VALUE));
|
|
|
|
|
|
assertFailures(client().prepareSearch("companies").setQuery(matchAllQuery())
|
|
|
- .addSort(SortBuilders.geoDistanceSort("branches.location").point(40.7143528, -74.0059731).sortMode("sum")),
|
|
|
+ .addSort(SortBuilders.geoDistanceSort("branches.location").point(40.7143528, -74.0059731).sortMode("sum").setNestedPath("branches")),
|
|
|
RestStatus.BAD_REQUEST,
|
|
|
containsString("sort_mode [sum] isn't supported for sorting by geo distance"));
|
|
|
}
|