Optimized LatLon sorting does not work in the descending order.

This commit is contained in:
Adrien Grand 2016-10-04 11:28:07 +02:00
parent 729804cb60
commit ff245a72c5
2 changed files with 6 additions and 0 deletions

View File

@ -558,6 +558,7 @@ public class GeoDistanceSortBuilder extends SortBuilder<GeoDistanceSortBuilder>
&& 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()),

View File

@ -501,5 +501,10 @@ public class GeoDistanceSortBuilderTests extends AbstractSortTestCase<GeoDistanc
builder.setNestedPath("some_nested_path");
sort = builder.build(context);
assertEquals(SortField.class, sort.field.getClass()); // can't use LatLon optimized sorting with nested fields
builder = new GeoDistanceSortBuilder("random_field_name", new GeoPoint(3.5, 2.1));
builder.order(SortOrder.DESC);
sort = builder.build(context);
assertEquals(SortField.class, sort.field.getClass()); // can't use LatLon optimized sorting with DESC sorting
}
}