diff --git a/server/src/main/java/org/opensearch/action/search/SearchPhaseController.java b/server/src/main/java/org/opensearch/action/search/SearchPhaseController.java index 84f2578eb6e2b..9b6f904c99c4c 100644 --- a/server/src/main/java/org/opensearch/action/search/SearchPhaseController.java +++ b/server/src/main/java/org/opensearch/action/search/SearchPhaseController.java @@ -623,11 +623,12 @@ private static Sort createSort(TopFieldDocs[] topFieldDocs) { SortField.Type sortType = getSortType(sortField); if (SortedWiderNumericSortField.isTypeSupported(sortType) == false) { // throw exception if sortType is not CUSTOM? + // skip this shard or do not widen? requireWiden = false; break; } - requireWiden = sortType != firstType; - isFloat = sortType == SortField.Type.FLOAT || sortType == SortField.Type.DOUBLE; + requireWiden = requireWiden || sortType != firstType; + isFloat = isFloat || sortType == SortField.Type.FLOAT || sortType == SortField.Type.DOUBLE; } if (requireWiden) {