From e6aed145af24054fc44336367d251ce03a34c371 Mon Sep 17 00:00:00 2001 From: Varun Jain Date: Mon, 13 Jan 2025 12:25:57 -0800 Subject: [PATCH] Sending empty hybrid query context Signed-off-by: Varun Jain --- .../neuralsearch/query/HybridQueryBuilder.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) 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); } /**