Example usage for org.apache.lucene.search QueryCachingPolicy shouldCache

List of usage examples for org.apache.lucene.search QueryCachingPolicy shouldCache

Introduction

In this page you can find the example usage for org.apache.lucene.search QueryCachingPolicy shouldCache.

Prototype

boolean shouldCache(Query query) throws IOException;

Source Link

Document

Whether the given Query is worth caching.

Usage

From source file:org.elasticsearch.index.shard.ElasticsearchQueryCachingPolicyTests.java

License:Apache License

public void testDoesNotCacheTermQueries() throws IOException {
    QueryCachingPolicy policy = QueryCachingPolicy.ALWAYS_CACHE;
    assertTrue(policy.shouldCache(new TermQuery(new Term("foo", "bar"))));
    assertTrue(policy.shouldCache(new PhraseQuery("foo", "bar", "baz")));
    policy = new ElasticsearchQueryCachingPolicy(policy);
    assertFalse(policy.shouldCache(new TermQuery(new Term("foo", "bar"))));
    assertTrue(policy.shouldCache(new PhraseQuery("foo", "bar", "baz")));
}