From 7e4e1d33f13469948dcb05a6bf7e3199c23c43ca Mon Sep 17 00:00:00 2001 From: Jim Ferenczi Date: Tue, 8 Oct 2024 22:19:46 +0100 Subject: [PATCH] fix npe --- .../search/retriever/StandardRetrieverBuilder.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/search/retriever/StandardRetrieverBuilder.java b/server/src/main/java/org/elasticsearch/search/retriever/StandardRetrieverBuilder.java index dd5d596e11728..4c965a12558f0 100644 --- a/server/src/main/java/org/elasticsearch/search/retriever/StandardRetrieverBuilder.java +++ b/server/src/main/java/org/elasticsearch/search/retriever/StandardRetrieverBuilder.java @@ -131,8 +131,11 @@ public RetrieverBuilder rewrite(QueryRewriteContext ctx) throws IOException { var rewrittenFilters = rewritePreFilters(ctx); changed |= rewrittenFilters != preFilterQueryBuilders; - var queryBuilderRewrite = queryBuilder.rewrite(ctx); - changed |= queryBuilderRewrite != queryBuilder; + QueryBuilder queryBuilderRewrite = null; + if (queryBuilder != null) { + queryBuilderRewrite = queryBuilder.rewrite(ctx); + changed |= queryBuilderRewrite != queryBuilder; + } if (changed) { var rewritten = new StandardRetrieverBuilder(this);