diff --git a/src/main/java/org/opensearch/neuralsearch/query/HybridQueryBuilder.java b/src/main/java/org/opensearch/neuralsearch/query/HybridQueryBuilder.java index c41f14094..b2b2dfa42 100644 --- a/src/main/java/org/opensearch/neuralsearch/query/HybridQueryBuilder.java +++ b/src/main/java/org/opensearch/neuralsearch/query/HybridQueryBuilder.java @@ -128,9 +128,12 @@ protected Query doToQuery(QueryShardContext queryShardContext) throws IOExceptio if (queryCollection.isEmpty()) { return Queries.newMatchNoDocsQuery(String.format(Locale.ROOT, "no clauses for %s query", NAME)); } - validatePaginationDepth(paginationDepth, queryShardContext); - HybridQueryContext hybridQueryContext = HybridQueryContext.builder().paginationDepth(paginationDepth).build(); - return new HybridQuery(queryCollection, hybridQueryContext); + if (isClusterOnOrAfterMinReqVersionForPaginationInHybridQuery()) { + validatePaginationDepth(paginationDepth, queryShardContext); + HybridQueryContext hybridQueryContext = HybridQueryContext.builder().paginationDepth(paginationDepth).build(); + return new HybridQuery(queryCollection, hybridQueryContext); + } + return new HybridQuery(queryCollection, null); } /**