From 54458e35c1ce23bda90da220fa7ae97b5b92c257 Mon Sep 17 00:00:00 2001 From: Jim Ferenczi Date: Fri, 13 Dec 2024 12:09:52 +0000 Subject: [PATCH] add missing size validation --- .../retriever/CompoundRetrieverBuilder.java | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) 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;