|
@@ -270,7 +270,7 @@ public class GeoDistanceIT extends ESIntegTestCase {
|
|
|
|
|
|
// Order: Asc, Mode: max
|
|
|
searchResponse = client().prepareSearch("test").setQuery(matchAllQuery())
|
|
|
- .addSort(SortBuilders.geoDistanceSort("locations", 40.7143528, -74.0059731).order(SortOrder.ASC).sortMode("max"))
|
|
|
+ .addSort(SortBuilders.geoDistanceSort("locations", 40.7143528, -74.0059731).order(SortOrder.ASC).sortMode(SortMode.MAX))
|
|
|
.execute().actionGet();
|
|
|
|
|
|
assertHitCount(searchResponse, 5);
|
|
@@ -296,7 +296,7 @@ public class GeoDistanceIT extends ESIntegTestCase {
|
|
|
|
|
|
// Order: Desc, Mode: min
|
|
|
searchResponse = client().prepareSearch("test").setQuery(matchAllQuery())
|
|
|
- .addSort(SortBuilders.geoDistanceSort("locations", 40.7143528, -74.0059731).order(SortOrder.DESC).sortMode("min"))
|
|
|
+ .addSort(SortBuilders.geoDistanceSort("locations", 40.7143528, -74.0059731).order(SortOrder.DESC).sortMode(SortMode.MIN))
|
|
|
.execute().actionGet();
|
|
|
|
|
|
assertHitCount(searchResponse, 5);
|
|
@@ -308,7 +308,7 @@ public class GeoDistanceIT extends ESIntegTestCase {
|
|
|
assertThat(((Number) searchResponse.getHits().getAt(4).sortValues()[0]).doubleValue(), closeTo(0d, 10d));
|
|
|
|
|
|
searchResponse = client().prepareSearch("test").setQuery(matchAllQuery())
|
|
|
- .addSort(SortBuilders.geoDistanceSort("locations", 40.7143528, -74.0059731).sortMode("avg").order(SortOrder.ASC))
|
|
|
+ .addSort(SortBuilders.geoDistanceSort("locations", 40.7143528, -74.0059731).sortMode(SortMode.AVG).order(SortOrder.ASC))
|
|
|
.execute().actionGet();
|
|
|
|
|
|
assertHitCount(searchResponse, 5);
|
|
@@ -320,7 +320,7 @@ public class GeoDistanceIT extends ESIntegTestCase {
|
|
|
assertThat(((Number) searchResponse.getHits().getAt(4).sortValues()[0]).doubleValue(), closeTo(5301d, 10d));
|
|
|
|
|
|
searchResponse = client().prepareSearch("test").setQuery(matchAllQuery())
|
|
|
- .addSort(SortBuilders.geoDistanceSort("locations", 40.7143528, -74.0059731).sortMode("avg").order(SortOrder.DESC))
|
|
|
+ .addSort(SortBuilders.geoDistanceSort("locations", 40.7143528, -74.0059731).sortMode(SortMode.AVG).order(SortOrder.DESC))
|
|
|
.execute().actionGet();
|
|
|
|
|
|
assertHitCount(searchResponse, 5);
|
|
@@ -333,7 +333,7 @@ public class GeoDistanceIT extends ESIntegTestCase {
|
|
|
|
|
|
try {
|
|
|
client().prepareSearch("test").setQuery(matchAllQuery())
|
|
|
- .addSort(SortBuilders.geoDistanceSort("locations", 40.7143528, -74.0059731).sortMode("sum"));
|
|
|
+ .addSort(SortBuilders.geoDistanceSort("locations", 40.7143528, -74.0059731).sortMode(SortMode.SUM));
|
|
|
fail("sum should not be supported for sorting by geo distance");
|
|
|
} catch (IllegalArgumentException e) {
|
|
|
// expected
|
|
@@ -455,7 +455,7 @@ public class GeoDistanceIT extends ESIntegTestCase {
|
|
|
// Order: Asc, Mode: max
|
|
|
searchResponse = client()
|
|
|
.prepareSearch("companies").setQuery(matchAllQuery()).addSort(SortBuilders.geoDistanceSort("branches.location",
|
|
|
- 40.7143528, -74.0059731).order(SortOrder.ASC).sortMode("max").setNestedPath("branches"))
|
|
|
+ 40.7143528, -74.0059731).order(SortOrder.ASC).sortMode(SortMode.MAX).setNestedPath("branches"))
|
|
|
.execute().actionGet();
|
|
|
|
|
|
assertHitCount(searchResponse, 4);
|
|
@@ -480,7 +480,7 @@ public class GeoDistanceIT extends ESIntegTestCase {
|
|
|
// Order: Desc, Mode: min
|
|
|
searchResponse = client()
|
|
|
.prepareSearch("companies").setQuery(matchAllQuery()).addSort(SortBuilders.geoDistanceSort("branches.location",
|
|
|
- 40.7143528, -74.0059731).order(SortOrder.DESC).sortMode("min").setNestedPath("branches"))
|
|
|
+ 40.7143528, -74.0059731).order(SortOrder.DESC).sortMode(SortMode.MIN).setNestedPath("branches"))
|
|
|
.execute().actionGet();
|
|
|
|
|
|
assertHitCount(searchResponse, 4);
|
|
@@ -492,7 +492,7 @@ public class GeoDistanceIT extends ESIntegTestCase {
|
|
|
|
|
|
searchResponse = client()
|
|
|
.prepareSearch("companies").setQuery(matchAllQuery()).addSort(SortBuilders.geoDistanceSort("branches.location",
|
|
|
- 40.7143528, -74.0059731).sortMode("avg").order(SortOrder.ASC).setNestedPath("branches"))
|
|
|
+ 40.7143528, -74.0059731).sortMode(SortMode.AVG).order(SortOrder.ASC).setNestedPath("branches"))
|
|
|
.execute().actionGet();
|
|
|
|
|
|
assertHitCount(searchResponse, 4);
|
|
@@ -504,7 +504,7 @@ public class GeoDistanceIT extends ESIntegTestCase {
|
|
|
|
|
|
searchResponse = client().prepareSearch("companies")
|
|
|
.setQuery(matchAllQuery()).addSort(SortBuilders.geoDistanceSort("branches.location", 40.7143528, -74.0059731)
|
|
|
- .setNestedPath("branches").sortMode("avg").order(SortOrder.DESC).setNestedPath("branches"))
|
|
|
+ .setNestedPath("branches").sortMode(SortMode.AVG).order(SortOrder.DESC).setNestedPath("branches"))
|
|
|
.execute().actionGet();
|
|
|
|
|
|
assertHitCount(searchResponse, 4);
|
|
@@ -517,7 +517,7 @@ public class GeoDistanceIT extends ESIntegTestCase {
|
|
|
searchResponse = client().prepareSearch("companies").setQuery(matchAllQuery())
|
|
|
.addSort(SortBuilders.geoDistanceSort("branches.location", 40.7143528, -74.0059731)
|
|
|
.setNestedFilter(termQuery("branches.name", "brooklyn"))
|
|
|
- .sortMode("avg").order(SortOrder.ASC).setNestedPath("branches"))
|
|
|
+ .sortMode(SortMode.AVG).order(SortOrder.ASC).setNestedPath("branches"))
|
|
|
.execute().actionGet();
|
|
|
assertHitCount(searchResponse, 4);
|
|
|
assertFirstHit(searchResponse, hasId("4"));
|
|
@@ -529,7 +529,7 @@ public class GeoDistanceIT extends ESIntegTestCase {
|
|
|
|
|
|
try {
|
|
|
client().prepareSearch("companies").setQuery(matchAllQuery())
|
|
|
- .addSort(SortBuilders.geoDistanceSort("branches.location", 40.7143528, -74.0059731).sortMode("sum")
|
|
|
+ .addSort(SortBuilders.geoDistanceSort("branches.location", 40.7143528, -74.0059731).sortMode(SortMode.SUM)
|
|
|
.setNestedPath("branches"));
|
|
|
fail("Sum should not be allowed as sort mode");
|
|
|
} catch (IllegalArgumentException e) {
|
|
@@ -567,11 +567,11 @@ public class GeoDistanceIT extends ESIntegTestCase {
|
|
|
assertHitCount(result, 1);
|
|
|
}
|
|
|
|
|
|
- private double randomLon() {
|
|
|
+ private static double randomLon() {
|
|
|
return randomDouble() * 360 - 180;
|
|
|
}
|
|
|
|
|
|
- private double randomLat() {
|
|
|
+ private static double randomLat() {
|
|
|
return randomDouble() * 180 - 90;
|
|
|
}
|
|
|
|
|
@@ -619,7 +619,7 @@ public class GeoDistanceIT extends ESIntegTestCase {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private long assertDuelOptimization(SearchResponse resp) {
|
|
|
+ private static long assertDuelOptimization(SearchResponse resp) {
|
|
|
long matches = -1;
|
|
|
assertSearchResponse(resp);
|
|
|
if (matches < 0) {
|