Skip to content

Commit

Permalink
Remove deprecated sort mode from geo_sort
Browse files Browse the repository at this point in the history
This removes the deprecated `sort_mode` key from `_geo_distance`
sorting. It's been deprecated since 5.0.
  • Loading branch information
nik9000 committed Jan 8, 2025
1 parent c3e11a7 commit dfd59ca
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public class GeoDistanceSortBuilder extends SortBuilder<GeoDistanceSortBuilder>
private static final ParseField UNIT_FIELD = new ParseField("unit");
private static final ParseField DISTANCE_TYPE_FIELD = new ParseField("distance_type");
private static final ParseField VALIDATION_METHOD_FIELD = new ParseField("validation_method");
private static final ParseField SORTMODE_FIELD = new ParseField("mode", "sort_mode");
private static final ParseField SORTMODE_FIELD = new ParseField("mode");
private static final ParseField IGNORE_UNMAPPED = new ParseField("ignore_unmapped");

private final String fieldName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -333,20 +333,6 @@ public void testGeoDistanceSortParserManyPointsNoException() throws Exception {
parse(sortBuilder);
}

public void testGeoDistanceSortDeprecatedSortModeException() throws Exception {
XContentBuilder sortBuilder = jsonBuilder();
sortBuilder.startObject();
sortBuilder.startArray("location");
sortBuilder.startArray().value(1.2).value(3).endArray().startArray().value(5).value(6).endArray();
sortBuilder.endArray();
sortBuilder.field("order", "desc");
sortBuilder.field("unit", "km");
sortBuilder.field("sort_mode", "max");
sortBuilder.endObject();
parse(sortBuilder);
assertWarnings("Deprecated field [sort_mode] used, expected [mode] instead");
}

private GeoDistanceSortBuilder parse(XContentBuilder sortBuilder) throws Exception {
try (XContentParser parser = createParser(sortBuilder)) {
parser.nextToken();
Expand Down

0 comments on commit dfd59ca

Please sign in to comment.