Remove in-place rewriting of SearchSourceBuilder
SearchSourceBuilder should be cloned when rewriting, the in-place rewrite is failing with local transport assertions.
This commit is contained in:
parent
25943eb00b
commit
8c1fe37e92
|
@ -533,9 +533,6 @@ public class SearchService extends AbstractLifecycleComponent<SearchService> imp
|
||||||
DefaultSearchContext context = new DefaultSearchContext(idGenerator.incrementAndGet(), request, shardTarget, engineSearcher, indexService, indexShard, scriptService, pageCacheRecycler, bigArrays, threadPool.estimatedTimeInMillisCounter(), parseFieldMatcher, defaultSearchTimeout);
|
DefaultSearchContext context = new DefaultSearchContext(idGenerator.incrementAndGet(), request, shardTarget, engineSearcher, indexService, indexShard, scriptService, pageCacheRecycler, bigArrays, threadPool.estimatedTimeInMillisCounter(), parseFieldMatcher, defaultSearchTimeout);
|
||||||
SearchContext.setCurrent(context);
|
SearchContext.setCurrent(context);
|
||||||
try {
|
try {
|
||||||
if (request.source() != null) {
|
|
||||||
request.source().rewrite(context.getQueryShardContext());
|
|
||||||
}
|
|
||||||
if (request.scroll() != null) {
|
if (request.scroll() != null) {
|
||||||
context.scrollContext(new ScrollContext());
|
context.scrollContext(new ScrollContext());
|
||||||
context.scrollContext().scroll = request.scroll();
|
context.scrollContext().scroll = request.scroll();
|
||||||
|
|
|
@ -1435,16 +1435,4 @@ public final class SearchSourceBuilder extends ToXContentToBytes implements Writ
|
||||||
&& Objects.equals(profile, other.profile);
|
&& 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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -488,14 +488,4 @@ public class SearchSourceBuilderTests extends ESTestCase {
|
||||||
String query = "{ \"post_filter\": {} }";
|
String query = "{ \"post_filter\": {} }";
|
||||||
assertParseSearchSource(builder, new BytesArray(query));
|
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());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue