Skip to content

Commit

Permalink
Fix test failure in FunctionScoreQueryBuilderTests.testCacheability (e…
Browse files Browse the repository at this point in the history
…lastic#55343)

We rewrite more query builders to MatchNoneQueryBuilders now, which are always
cacheable. We should make sure the tests expects this when the rewritten query
is a MatchNoneQueryBuilder.

Closes elastic#55331
  • Loading branch information
Christoph Büscher committed Apr 17, 2020
1 parent 71855fb commit 389b649
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
package org.elasticsearch.index.query.functionscore;

import com.fasterxml.jackson.core.JsonParseException;

import org.apache.lucene.index.Term;
import org.apache.lucene.search.MatchAllDocsQuery;
import org.apache.lucene.search.MatchNoDocsQuery;
Expand Down Expand Up @@ -829,6 +830,10 @@ public void testCacheability() throws IOException {
QueryShardContext context = createShardContext();
QueryBuilder rewriteQuery = rewriteQuery(queryBuilder, new QueryShardContext(context));
assertNotNull(rewriteQuery.toQuery(context));
// we occasionally need to update the expected "isCacheable" flag after rewrite for MatchNoneQueryBuilder
if (rewriteQuery instanceof MatchNoneQueryBuilder) {
isCacheable = true;
}
assertEquals("query should " + (isCacheable ? "" : "not") + " be cacheable: " + queryBuilder.toString(), isCacheable,
context.isCacheable());

Expand Down

0 comments on commit 389b649

Please sign in to comment.