|
@@ -95,7 +95,7 @@ public class GeoDistanceSortBuilderIT extends ESIntegTestCase {
|
|
|
|
|
|
|
|
SearchResponse searchResponse = client().prepareSearch()
|
|
SearchResponse searchResponse = client().prepareSearch()
|
|
|
.setQuery(matchAllQuery())
|
|
.setQuery(matchAllQuery())
|
|
|
- .addSort(new GeoDistanceSortBuilder("location", q).sortMode("min").order(SortOrder.ASC).geoDistance(GeoDistance.PLANE).unit(DistanceUnit.KILOMETERS))
|
|
|
|
|
|
|
+ .addSort(new GeoDistanceSortBuilder("location", q).sortMode(SortMode.MIN).order(SortOrder.ASC).geoDistance(GeoDistance.PLANE).unit(DistanceUnit.KILOMETERS))
|
|
|
.execute().actionGet();
|
|
.execute().actionGet();
|
|
|
assertOrderedSearchHits(searchResponse, "d1", "d2");
|
|
assertOrderedSearchHits(searchResponse, "d1", "d2");
|
|
|
assertThat((Double)searchResponse.getHits().getAt(0).getSortValues()[0], closeTo(GeoDistance.PLANE.calculate(2, 2, 3, 2, DistanceUnit.KILOMETERS), 0.01d));
|
|
assertThat((Double)searchResponse.getHits().getAt(0).getSortValues()[0], closeTo(GeoDistance.PLANE.calculate(2, 2, 3, 2, DistanceUnit.KILOMETERS), 0.01d));
|
|
@@ -103,7 +103,7 @@ public class GeoDistanceSortBuilderIT extends ESIntegTestCase {
|
|
|
|
|
|
|
|
searchResponse = client().prepareSearch()
|
|
searchResponse = client().prepareSearch()
|
|
|
.setQuery(matchAllQuery())
|
|
.setQuery(matchAllQuery())
|
|
|
- .addSort(new GeoDistanceSortBuilder("location", q).sortMode("min").order(SortOrder.DESC).geoDistance(GeoDistance.PLANE).unit(DistanceUnit.KILOMETERS))
|
|
|
|
|
|
|
+ .addSort(new GeoDistanceSortBuilder("location", q).sortMode(SortMode.MIN).order(SortOrder.DESC).geoDistance(GeoDistance.PLANE).unit(DistanceUnit.KILOMETERS))
|
|
|
.execute().actionGet();
|
|
.execute().actionGet();
|
|
|
assertOrderedSearchHits(searchResponse, "d2", "d1");
|
|
assertOrderedSearchHits(searchResponse, "d2", "d1");
|
|
|
assertThat((Double)searchResponse.getHits().getAt(0).getSortValues()[0], closeTo(GeoDistance.PLANE.calculate(2, 1, 5, 1, DistanceUnit.KILOMETERS), 0.01d));
|
|
assertThat((Double)searchResponse.getHits().getAt(0).getSortValues()[0], closeTo(GeoDistance.PLANE.calculate(2, 1, 5, 1, DistanceUnit.KILOMETERS), 0.01d));
|
|
@@ -111,7 +111,7 @@ public class GeoDistanceSortBuilderIT extends ESIntegTestCase {
|
|
|
|
|
|
|
|
searchResponse = client().prepareSearch()
|
|
searchResponse = client().prepareSearch()
|
|
|
.setQuery(matchAllQuery())
|
|
.setQuery(matchAllQuery())
|
|
|
- .addSort(new GeoDistanceSortBuilder("location", q).sortMode("max").order(SortOrder.ASC).geoDistance(GeoDistance.PLANE).unit(DistanceUnit.KILOMETERS))
|
|
|
|
|
|
|
+ .addSort(new GeoDistanceSortBuilder("location", q).sortMode(SortMode.MAX).order(SortOrder.ASC).geoDistance(GeoDistance.PLANE).unit(DistanceUnit.KILOMETERS))
|
|
|
.execute().actionGet();
|
|
.execute().actionGet();
|
|
|
assertOrderedSearchHits(searchResponse, "d1", "d2");
|
|
assertOrderedSearchHits(searchResponse, "d1", "d2");
|
|
|
assertThat((Double)searchResponse.getHits().getAt(0).getSortValues()[0], closeTo(GeoDistance.PLANE.calculate(2, 2, 4, 1, DistanceUnit.KILOMETERS), 0.01d));
|
|
assertThat((Double)searchResponse.getHits().getAt(0).getSortValues()[0], closeTo(GeoDistance.PLANE.calculate(2, 2, 4, 1, DistanceUnit.KILOMETERS), 0.01d));
|
|
@@ -119,7 +119,7 @@ public class GeoDistanceSortBuilderIT extends ESIntegTestCase {
|
|
|
|
|
|
|
|
searchResponse = client().prepareSearch()
|
|
searchResponse = client().prepareSearch()
|
|
|
.setQuery(matchAllQuery())
|
|
.setQuery(matchAllQuery())
|
|
|
- .addSort(new GeoDistanceSortBuilder("location", q).sortMode("max").order(SortOrder.DESC).geoDistance(GeoDistance.PLANE).unit(DistanceUnit.KILOMETERS))
|
|
|
|
|
|
|
+ .addSort(new GeoDistanceSortBuilder("location", q).sortMode(SortMode.MAX).order(SortOrder.DESC).geoDistance(GeoDistance.PLANE).unit(DistanceUnit.KILOMETERS))
|
|
|
.execute().actionGet();
|
|
.execute().actionGet();
|
|
|
assertOrderedSearchHits(searchResponse, "d2", "d1");
|
|
assertOrderedSearchHits(searchResponse, "d2", "d1");
|
|
|
assertThat((Double)searchResponse.getHits().getAt(0).getSortValues()[0], closeTo(GeoDistance.PLANE.calculate(2, 1, 6, 2, DistanceUnit.KILOMETERS), 0.01d));
|
|
assertThat((Double)searchResponse.getHits().getAt(0).getSortValues()[0], closeTo(GeoDistance.PLANE.calculate(2, 1, 6, 2, DistanceUnit.KILOMETERS), 0.01d));
|
|
@@ -194,7 +194,7 @@ public class GeoDistanceSortBuilderIT extends ESIntegTestCase {
|
|
|
|
|
|
|
|
SearchResponse searchResponse = client().prepareSearch()
|
|
SearchResponse searchResponse = client().prepareSearch()
|
|
|
.setQuery(matchAllQuery())
|
|
.setQuery(matchAllQuery())
|
|
|
- .addSort(geoDistanceSortBuilder.sortMode("min").order(SortOrder.ASC).geoDistance(GeoDistance.PLANE).unit(DistanceUnit.KILOMETERS))
|
|
|
|
|
|
|
+ .addSort(geoDistanceSortBuilder.sortMode(SortMode.MIN).order(SortOrder.ASC).geoDistance(GeoDistance.PLANE).unit(DistanceUnit.KILOMETERS))
|
|
|
.execute().actionGet();
|
|
.execute().actionGet();
|
|
|
assertOrderedSearchHits(searchResponse, "d1", "d2");
|
|
assertOrderedSearchHits(searchResponse, "d1", "d2");
|
|
|
assertThat((Double) searchResponse.getHits().getAt(0).getSortValues()[0], closeTo(GeoDistance.PLANE.calculate(2.5, 1, 2, 1, DistanceUnit.KILOMETERS), 1.e-4));
|
|
assertThat((Double) searchResponse.getHits().getAt(0).getSortValues()[0], closeTo(GeoDistance.PLANE.calculate(2.5, 1, 2, 1, DistanceUnit.KILOMETERS), 1.e-4));
|
|
@@ -202,7 +202,7 @@ public class GeoDistanceSortBuilderIT extends ESIntegTestCase {
|
|
|
|
|
|
|
|
searchResponse = client().prepareSearch()
|
|
searchResponse = client().prepareSearch()
|
|
|
.setQuery(matchAllQuery())
|
|
.setQuery(matchAllQuery())
|
|
|
- .addSort(geoDistanceSortBuilder.sortMode("max").order(SortOrder.ASC).geoDistance(GeoDistance.PLANE).unit(DistanceUnit.KILOMETERS))
|
|
|
|
|
|
|
+ .addSort(geoDistanceSortBuilder.sortMode(SortMode.MAX).order(SortOrder.ASC).geoDistance(GeoDistance.PLANE).unit(DistanceUnit.KILOMETERS))
|
|
|
.execute().actionGet();
|
|
.execute().actionGet();
|
|
|
assertOrderedSearchHits(searchResponse, "d1", "d2");
|
|
assertOrderedSearchHits(searchResponse, "d1", "d2");
|
|
|
assertThat((Double) searchResponse.getHits().getAt(0).getSortValues()[0], closeTo(GeoDistance.PLANE.calculate(3.25, 4, 2, 1, DistanceUnit.KILOMETERS), 1.e-4));
|
|
assertThat((Double) searchResponse.getHits().getAt(0).getSortValues()[0], closeTo(GeoDistance.PLANE.calculate(3.25, 4, 2, 1, DistanceUnit.KILOMETERS), 1.e-4));
|
|
@@ -223,7 +223,7 @@ public class GeoDistanceSortBuilderIT extends ESIntegTestCase {
|
|
|
|
|
|
|
|
SearchResponse searchResponse = client().prepareSearch()
|
|
SearchResponse searchResponse = client().prepareSearch()
|
|
|
.setQuery(matchAllQuery())
|
|
.setQuery(matchAllQuery())
|
|
|
- .addSort(geoDistanceSortBuilder.sortMode("min").order(SortOrder.ASC).geoDistance(GeoDistance.PLANE).unit(DistanceUnit.KILOMETERS))
|
|
|
|
|
|
|
+ .addSort(geoDistanceSortBuilder.sortMode(SortMode.MIN).order(SortOrder.ASC).geoDistance(GeoDistance.PLANE).unit(DistanceUnit.KILOMETERS))
|
|
|
.execute().actionGet();
|
|
.execute().actionGet();
|
|
|
checkCorrectSortOrderForGeoSort(searchResponse);
|
|
checkCorrectSortOrderForGeoSort(searchResponse);
|
|
|
|
|
|
|
@@ -231,7 +231,7 @@ public class GeoDistanceSortBuilderIT extends ESIntegTestCase {
|
|
|
|
|
|
|
|
searchResponse = client().prepareSearch()
|
|
searchResponse = client().prepareSearch()
|
|
|
.setQuery(matchAllQuery())
|
|
.setQuery(matchAllQuery())
|
|
|
- .addSort(geoDistanceSortBuilder.sortMode("min").order(SortOrder.ASC).geoDistance(GeoDistance.PLANE).unit(DistanceUnit.KILOMETERS))
|
|
|
|
|
|
|
+ .addSort(geoDistanceSortBuilder.sortMode(SortMode.MIN).order(SortOrder.ASC).geoDistance(GeoDistance.PLANE).unit(DistanceUnit.KILOMETERS))
|
|
|
.execute().actionGet();
|
|
.execute().actionGet();
|
|
|
checkCorrectSortOrderForGeoSort(searchResponse);
|
|
checkCorrectSortOrderForGeoSort(searchResponse);
|
|
|
|
|
|
|
@@ -239,7 +239,7 @@ public class GeoDistanceSortBuilderIT extends ESIntegTestCase {
|
|
|
|
|
|
|
|
searchResponse = client().prepareSearch()
|
|
searchResponse = client().prepareSearch()
|
|
|
.setQuery(matchAllQuery())
|
|
.setQuery(matchAllQuery())
|
|
|
- .addSort(geoDistanceSortBuilder.sortMode("min").order(SortOrder.ASC).geoDistance(GeoDistance.PLANE).unit(DistanceUnit.KILOMETERS))
|
|
|
|
|
|
|
+ .addSort(geoDistanceSortBuilder.sortMode(SortMode.MIN).order(SortOrder.ASC).geoDistance(GeoDistance.PLANE).unit(DistanceUnit.KILOMETERS))
|
|
|
.execute().actionGet();
|
|
.execute().actionGet();
|
|
|
checkCorrectSortOrderForGeoSort(searchResponse);
|
|
checkCorrectSortOrderForGeoSort(searchResponse);
|
|
|
|
|
|
|
@@ -265,7 +265,7 @@ public class GeoDistanceSortBuilderIT extends ESIntegTestCase {
|
|
|
checkCorrectSortOrderForGeoSort(searchResponse);
|
|
checkCorrectSortOrderForGeoSort(searchResponse);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private void checkCorrectSortOrderForGeoSort(SearchResponse searchResponse) {
|
|
|
|
|
|
|
+ private static void checkCorrectSortOrderForGeoSort(SearchResponse searchResponse) {
|
|
|
assertOrderedSearchHits(searchResponse, "d2", "d1");
|
|
assertOrderedSearchHits(searchResponse, "d2", "d1");
|
|
|
assertThat((Double) searchResponse.getHits().getAt(0).getSortValues()[0], closeTo(GeoDistance.PLANE.calculate(2, 2, 1, 2, DistanceUnit.KILOMETERS), 1.e-4));
|
|
assertThat((Double) searchResponse.getHits().getAt(0).getSortValues()[0], closeTo(GeoDistance.PLANE.calculate(2, 2, 1, 2, DistanceUnit.KILOMETERS), 1.e-4));
|
|
|
assertThat((Double) searchResponse.getHits().getAt(1).getSortValues()[0], closeTo(GeoDistance.PLANE.calculate(2, 2, 1, 1, DistanceUnit.KILOMETERS), 1.e-4));
|
|
assertThat((Double) searchResponse.getHits().getAt(1).getSortValues()[0], closeTo(GeoDistance.PLANE.calculate(2, 2, 1, 1, DistanceUnit.KILOMETERS), 1.e-4));
|