diff --git a/server/src/main/java/org/opensearch/index/fielddata/IndexNumericFieldData.java b/server/src/main/java/org/opensearch/index/fielddata/IndexNumericFieldData.java index 639b3f435b6a8..380b5dc60cc3f 100644 --- a/server/src/main/java/org/opensearch/index/fielddata/IndexNumericFieldData.java +++ b/server/src/main/java/org/opensearch/index/fielddata/IndexNumericFieldData.java @@ -109,6 +109,8 @@ public void modifySortFieldTypeForIndexSortIfNeeded() { */ public abstract NumericType getNumericType(); + private boolean indexSortField; + /** * Returns the {@link SortField} to used for sorting. * Values are casted to the provided targetNumericType type if it doesn't @@ -146,8 +148,8 @@ public final SortField sortField( SortField sortField = new SortedNumericSortField(getFieldName(), getNumericType().sortFieldType, reverse, selectorType); sortField.setMissingValue(source.missingObject(missingValue, reverse)); System.out.println(sortField); - if(reverse == false) { - throw new UnsupportedOperationException(); + if(indexSortField) { + sortField.setOptimizeSortWithPoints(false); } return sortField; } @@ -168,6 +170,7 @@ public final SortField sortField(Object missingValue, MultiValueMode sortMode, N public final SortField indexSortField(Object missingValue, MultiValueMode sortMode, Nested nested, boolean reverse) { System.out.println("CHETAN LOGS : coming here...."); getNumericType().modifySortFieldTypeForIndexSortIfNeeded(); + this.indexSortField = true; return sortField(getNumericType(), missingValue, sortMode, nested, reverse); }