diff --git a/server/src/main/java/org/elasticsearch/search/retriever/CompoundRetrieverBuilder.java b/server/src/main/java/org/elasticsearch/search/retriever/CompoundRetrieverBuilder.java index 0527179d42b73..cedbf9e1e75c3 100644 --- a/server/src/main/java/org/elasticsearch/search/retriever/CompoundRetrieverBuilder.java +++ b/server/src/main/java/org/elasticsearch/search/retriever/CompoundRetrieverBuilder.java @@ -233,15 +233,17 @@ public ActionRequestValidationException validate( for (RetrieverSource innerRetriever : innerRetrievers) { validationException = innerRetriever.retriever().validate(source, validationException, isScroll, allowPartialSearchResults); if (innerRetriever.retriever() instanceof CompoundRetrieverBuilder compoundChild) { - String errorMessage = String.format( - Locale.ROOT, - "[%s] requires [rank_window_size: %d] to be smaller than or equal to its sub retriever's %s [rank_window_size: %d]", - this.getName(), - rankWindowSize, - compoundChild.getName(), - compoundChild.rankWindowSize - ); - validationException = addValidationError(errorMessage, validationException); + if (rankWindowSize > compoundChild.rankWindowSize) { + String errorMessage = String.format( + Locale.ROOT, + "[%s] requires [rank_window_size: %d] to be smaller than or equal to its sub retriever's %s [rank_window_size: %d]", + this.getName(), + rankWindowSize, + compoundChild.getName(), + compoundChild.rankWindowSize + ); + validationException = addValidationError(errorMessage, validationException); + } } } return validationException;