From 85e4c21b0a9265b99a2e29ae9629a069e20a082b Mon Sep 17 00:00:00 2001 From: Adrien Grand Date: Wed, 8 Apr 2015 09:58:59 +0200 Subject: [PATCH] Tests: Disable the query cache for parent/child unit tests. --- .../search/child/AbstractChildTests.java | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src/test/java/org/elasticsearch/index/search/child/AbstractChildTests.java b/src/test/java/org/elasticsearch/index/search/child/AbstractChildTests.java index 242fa34787f..d08762e481a 100644 --- a/src/test/java/org/elasticsearch/index/search/child/AbstractChildTests.java +++ b/src/test/java/org/elasticsearch/index/search/child/AbstractChildTests.java @@ -19,7 +19,13 @@ package org.elasticsearch.index.search.child; -import org.apache.lucene.search.*; +import org.apache.lucene.search.DocIdSetIterator; +import org.apache.lucene.search.Filter; +import org.apache.lucene.search.IndexSearcher; +import org.apache.lucene.search.Query; +import org.apache.lucene.search.QueryCache; +import org.apache.lucene.search.ScoreDoc; +import org.apache.lucene.search.TopDocs; import org.apache.lucene.search.join.BitDocIdSetFilter; import org.apache.lucene.util.BitDocIdSet; import org.apache.lucene.util.BitSet; @@ -29,15 +35,17 @@ import org.elasticsearch.common.compress.CompressedString; import org.elasticsearch.common.xcontent.XContentHelper; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.index.Index; +import org.elasticsearch.index.IndexService; import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.index.mapper.internal.UidFieldMapper; import org.elasticsearch.index.query.QueryBuilder; import org.elasticsearch.index.query.QueryParseContext; -import org.elasticsearch.index.IndexService; import org.elasticsearch.search.internal.SearchContext; import org.elasticsearch.test.ElasticsearchSingleNodeLuceneTestCase; import org.hamcrest.Description; import org.hamcrest.StringDescription; +import org.junit.After; +import org.junit.Before; import org.junit.Ignore; import java.io.IOException; @@ -48,6 +56,19 @@ import static org.hamcrest.Matchers.equalTo; @LuceneTestCase.SuppressCodecs(value = {"Lucene40", "Lucene3x"}) public abstract class AbstractChildTests extends ElasticsearchSingleNodeLuceneTestCase { + // TODO: Parent/child does not work with the query cache + private static final QueryCache DEFAULT_QUERY_CACHE = IndexSearcher.getDefaultQueryCache(); + + @Before + public void disableQueryCache() { + IndexSearcher.setDefaultQueryCache(null); + } + + @After + public void restoreQueryCache() { + IndexSearcher.setDefaultQueryCache(DEFAULT_QUERY_CACHE); + } + /** * The name of the field within the child type that stores a score to use in test queries. *