Tests: Disable the query cache for parent/child unit tests.

This commit is contained in:
Adrien Grand 2015-04-08 09:58:59 +02:00
parent 717dbb0599
commit 85e4c21b0a
1 changed files with 23 additions and 2 deletions

View File

@ -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.
* <p />