diff --git a/core/src/main/java/org/elasticsearch/search/SearchService.java b/core/src/main/java/org/elasticsearch/search/SearchService.java index a52589c8641..0d116f264b9 100644 --- a/core/src/main/java/org/elasticsearch/search/SearchService.java +++ b/core/src/main/java/org/elasticsearch/search/SearchService.java @@ -533,9 +533,6 @@ public class SearchService extends AbstractLifecycleComponent imp DefaultSearchContext context = new DefaultSearchContext(idGenerator.incrementAndGet(), request, shardTarget, engineSearcher, indexService, indexShard, scriptService, pageCacheRecycler, bigArrays, threadPool.estimatedTimeInMillisCounter(), parseFieldMatcher, defaultSearchTimeout); SearchContext.setCurrent(context); try { - if (request.source() != null) { - request.source().rewrite(context.getQueryShardContext()); - } if (request.scroll() != null) { context.scrollContext(new ScrollContext()); context.scrollContext().scroll = request.scroll(); diff --git a/core/src/main/java/org/elasticsearch/search/builder/SearchSourceBuilder.java b/core/src/main/java/org/elasticsearch/search/builder/SearchSourceBuilder.java index 99ee939d15b..e60e6c5a0a0 100644 --- a/core/src/main/java/org/elasticsearch/search/builder/SearchSourceBuilder.java +++ b/core/src/main/java/org/elasticsearch/search/builder/SearchSourceBuilder.java @@ -1435,16 +1435,4 @@ public final class SearchSourceBuilder extends ToXContentToBytes implements Writ && Objects.equals(profile, other.profile); } - /** - * Rewrites the internal query builders in-place - */ - public void rewrite(QueryRewriteContext rewriteContext) throws IOException { - if (queryBuilder != null) { - queryBuilder = QueryBuilder.rewriteQuery(queryBuilder, rewriteContext); - } - if (postQueryBuilder != null) { - postQueryBuilder = QueryBuilder.rewriteQuery(postQueryBuilder, rewriteContext); - } - } - } diff --git a/core/src/test/java/org/elasticsearch/search/builder/SearchSourceBuilderTests.java b/core/src/test/java/org/elasticsearch/search/builder/SearchSourceBuilderTests.java index 5321d732be9..93577325070 100644 --- a/core/src/test/java/org/elasticsearch/search/builder/SearchSourceBuilderTests.java +++ b/core/src/test/java/org/elasticsearch/search/builder/SearchSourceBuilderTests.java @@ -488,14 +488,4 @@ public class SearchSourceBuilderTests extends ESTestCase { String query = "{ \"post_filter\": {} }"; assertParseSearchSource(builder, new BytesArray(query)); } - - public void testRewrite() throws IOException { - SearchSourceBuilder builder = new SearchSourceBuilder(); - builder.query(new BoolQueryBuilder()); - TermQueryBuilder tqb = new TermQueryBuilder("foo", "bar"); - builder.postFilter(new WrapperQueryBuilder(tqb.toString())); - builder.rewrite(new QueryRewriteContext(null, null, indicesQueriesRegistry)); - assertEquals(new MatchAllQueryBuilder(), builder.query()); - assertEquals(tqb, builder.postFilter()); - } }