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:
Simon Willnauer 2016-02-13 08:57:32 +01:00
parent 25943eb00b
commit 8c1fe37e92
3 changed files with 0 additions and 25 deletions

View File

@ -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);
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();

View File

@ -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);
}
}
}

View File

@ -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());
}
}