From ff245a72c59c5e33ded1f7b67d365facf590aa25 Mon Sep 17 00:00:00 2001 From: Adrien Grand Date: Tue, 4 Oct 2016 11:28:07 +0200 Subject: [PATCH] Optimized LatLon sorting does not work in the descending order. --- .../elasticsearch/search/sort/GeoDistanceSortBuilder.java | 1 + .../search/sort/GeoDistanceSortBuilderTests.java | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/core/src/main/java/org/elasticsearch/search/sort/GeoDistanceSortBuilder.java b/core/src/main/java/org/elasticsearch/search/sort/GeoDistanceSortBuilder.java index bcecc2ca497..9818e4076f8 100644 --- a/core/src/main/java/org/elasticsearch/search/sort/GeoDistanceSortBuilder.java +++ b/core/src/main/java/org/elasticsearch/search/sort/GeoDistanceSortBuilder.java @@ -558,6 +558,7 @@ public class GeoDistanceSortBuilder extends SortBuilder && nested == null && finalSortMode == MultiValueMode.MIN // LatLonDocValuesField internally picks the closest point && unit == DistanceUnit.METERS + && reverse == false && localPoints.size() == 1) { return new SortFieldAndFormat( LatLonDocValuesField.newDistanceSort(fieldName, localPoints.get(0).lat(), localPoints.get(0).lon()), diff --git a/core/src/test/java/org/elasticsearch/search/sort/GeoDistanceSortBuilderTests.java b/core/src/test/java/org/elasticsearch/search/sort/GeoDistanceSortBuilderTests.java index 6e3ac76e8a1..6fbd473f7ea 100644 --- a/core/src/test/java/org/elasticsearch/search/sort/GeoDistanceSortBuilderTests.java +++ b/core/src/test/java/org/elasticsearch/search/sort/GeoDistanceSortBuilderTests.java @@ -501,5 +501,10 @@ public class GeoDistanceSortBuilderTests extends AbstractSortTestCase