mirror of
https://github.com/spring-projects/spring-data-elasticsearch.git
synced 2025-07-07 19:22:10 +00:00
Adding GeoDistanceOrder's direction in request.
Original Pull Request #2602 Closes #2601
This commit is contained in:
parent
a2cbca57f6
commit
8a164b1039
@ -1499,6 +1499,7 @@ class RequestConverter {
|
||||
.field(fieldName) //
|
||||
.location(loc -> loc.latlon(Queries.latLon(geoDistanceOrder.getGeoPoint()))) //
|
||||
.distanceType(geoDistanceType(geoDistanceOrder.getDistanceType())).mode(sortMode(finalMode)) //
|
||||
.order(sortOrder(geoDistanceOrder.getDirection())) //
|
||||
.unit(distanceUnit(geoDistanceOrder.getUnit())) //
|
||||
.ignoreUnmapped(geoDistanceOrder.getIgnoreUnmapped())));
|
||||
} else {
|
||||
|
@ -28,6 +28,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.elasticsearch.core.RefreshPolicy;
|
||||
import org.springframework.data.elasticsearch.core.document.Document;
|
||||
import org.springframework.data.elasticsearch.core.query.*;
|
||||
@ -165,6 +166,20 @@ final class TypeUtils {
|
||||
|
||||
}
|
||||
|
||||
@Nullable
|
||||
static SortOrder sortOrder(@Nullable Sort.Direction direction) {
|
||||
|
||||
if (direction == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return switch (direction) {
|
||||
case ASC -> SortOrder.Asc;
|
||||
case DESC -> SortOrder.Desc;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@Nullable
|
||||
static HighlighterFragmenter highlighterFragmenter(@Nullable String value) {
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user