From e52625baadb3aa8c1b4fa86e96b87785523d9b9a Mon Sep 17 00:00:00 2001 From: Kathleen DeRusso Date: Tue, 10 Dec 2024 14:09:50 -0500 Subject: [PATCH] Cleanup --- .../index/query/AbstractQueryBuilder.java | 1 + .../query/InterceptedQueryBuilderWrapper.java | 8 +++-- .../index/query/QueryRewriteContext.java | 31 ------------------- 3 files changed, 7 insertions(+), 33 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/index/query/AbstractQueryBuilder.java b/server/src/main/java/org/elasticsearch/index/query/AbstractQueryBuilder.java index 5195a43b85a9a..b2c70180ab85c 100644 --- a/server/src/main/java/org/elasticsearch/index/query/AbstractQueryBuilder.java +++ b/server/src/main/java/org/elasticsearch/index/query/AbstractQueryBuilder.java @@ -286,6 +286,7 @@ public final QueryBuilder rewrite(QueryRewriteContext queryRewriteContext) throw return rewritten; } } + QueryBuilder rewritten = doRewrite(queryRewriteContext); if (rewritten == this) { return rewritten; diff --git a/server/src/main/java/org/elasticsearch/index/query/InterceptedQueryBuilderWrapper.java b/server/src/main/java/org/elasticsearch/index/query/InterceptedQueryBuilderWrapper.java index 820b3dd6abd9a..cb059bf757d42 100644 --- a/server/src/main/java/org/elasticsearch/index/query/InterceptedQueryBuilderWrapper.java +++ b/server/src/main/java/org/elasticsearch/index/query/InterceptedQueryBuilderWrapper.java @@ -19,7 +19,7 @@ import java.util.Objects; /** - * Wrapper for instances of {@link AbstractQueryBuilder} that have been intercepted using the {@link QueryRewriteInterceptor} to + * Wrapper for instances of {@link QueryBuilder} that have been intercepted using the {@link QueryRewriteInterceptor} to * break out of the rewrite phase. These instances are unwrapped on serialization. */ public class InterceptedQueryBuilderWrapper implements QueryBuilder { @@ -28,7 +28,11 @@ public class InterceptedQueryBuilderWrapper implements QueryBuilder { public InterceptedQueryBuilderWrapper(QueryBuilder queryBuilder) { super(); - this.queryBuilder = queryBuilder; + if (queryBuilder instanceof InterceptedQueryBuilderWrapper) { + this.queryBuilder = ((InterceptedQueryBuilderWrapper) queryBuilder).queryBuilder; + } else { + this.queryBuilder = queryBuilder; + } } @Override diff --git a/server/src/main/java/org/elasticsearch/index/query/QueryRewriteContext.java b/server/src/main/java/org/elasticsearch/index/query/QueryRewriteContext.java index cd0304afeca25..04b873f391448 100644 --- a/server/src/main/java/org/elasticsearch/index/query/QueryRewriteContext.java +++ b/server/src/main/java/org/elasticsearch/index/query/QueryRewriteContext.java @@ -160,37 +160,6 @@ public QueryRewriteContext( ); } - /** - * Returns a new {@link QueryRewriteContext} instance that is stripped of any - * configured interceptors, guaranteeing that downstream rewrites don't try to - * re-intercept the query. - */ - public QueryRewriteContext getInterceptedQueryRewriteContext() { - - if (queryRewriteInterceptor == null) { - return this; - } - - return new QueryRewriteContext( - parserConfiguration, - client, - nowInMillis, - mapperService, - mappingLookup, - runtimeMappings, - indexSettings, - fullyQualifiedIndex, - indexNameMatcher, - writeableRegistry, - valuesSourceRegistry, - allowExpensiveQueries, - scriptService, - resolvedIndices, - pit, - null - ); - } - /** * The registry used to build new {@link XContentParser}s. Contains registered named parsers needed to parse the query. *