Skip to content

Commit 389b649

Browse files
author
Christoph Büscher
committed
Fix test failure in FunctionScoreQueryBuilderTests.testCacheability (#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 #55331
1 parent 71855fb commit 389b649

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

server/src/test/java/org/elasticsearch/index/query/functionscore/FunctionScoreQueryBuilderTests.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
package org.elasticsearch.index.query.functionscore;
2121

2222
import com.fasterxml.jackson.core.JsonParseException;
23+
2324
import org.apache.lucene.index.Term;
2425
import org.apache.lucene.search.MatchAllDocsQuery;
2526
import org.apache.lucene.search.MatchNoDocsQuery;
@@ -829,6 +830,10 @@ public void testCacheability() throws IOException {
829830
QueryShardContext context = createShardContext();
830831
QueryBuilder rewriteQuery = rewriteQuery(queryBuilder, new QueryShardContext(context));
831832
assertNotNull(rewriteQuery.toQuery(context));
833+
// we occasionally need to update the expected "isCacheable" flag after rewrite for MatchNoneQueryBuilder
834+
if (rewriteQuery instanceof MatchNoneQueryBuilder) {
835+
isCacheable = true;
836+
}
832837
assertEquals("query should " + (isCacheable ? "" : "not") + " be cacheable: " + queryBuilder.toString(), isCacheable,
833838
context.isCacheable());
834839

0 commit comments

Comments
 (0)