Skip to content

Commit 443e7df

Browse files
Fix BWC tests
1 parent 2ea6efd commit 443e7df

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

server/src/main/java/org/elasticsearch/index/fielddata/IndexNumericFieldData.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,8 @@ public SortField sortField(
164164
);
165165
XFieldComparatorSource longSource = comparatorSource(NumericType.LONG, missingValue, sortMode, nested);
166166
rewrittenSortField.setMissingValue(longSource.missingObject(missingValue, reverse));
167-
rewrittenSortField.setOptimizeSortWithPoints(numericSortField.getOptimizeSortWithPoints());
167+
// we don't optimize sorting on int field for old indices
168+
rewrittenSortField.setOptimizeSortWithPoints(false);
168169
return rewrittenSortField;
169170
}
170171

server/src/main/java/org/elasticsearch/search/searchafter/SearchAfterBuilder.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,13 @@ static Object convertValueFromSortField(Object value, SortField sortField, DocVa
153153
private static Object convertValueFromSortType(String fieldName, SortField.Type sortType, Object value, DocValueFormat format) {
154154
try {
155155
switch (sortType) {
156-
case DOC, INT:
156+
case DOC:
157+
if (value instanceof Number valueNumber) {
158+
return (valueNumber).intValue();
159+
}
160+
return Integer.parseInt(value.toString());
161+
162+
case INT:
157163
// As mixing INT and LONG sort in a single request is allowed,
158164
// we may get search_after values that are larger than Integer.MAX_VALUE
159165
// in this case convert them to Integer.MAX_VALUE

0 commit comments

Comments
 (0)