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

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

Introduction

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

Prototype

void onUse(Query query);

Source Link

Document

Callback that is called every time that a cached filter is used.

Usage

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

License:Apache License

public void testDoesNotPutTermQueriesIntoTheHistory() {
    boolean[] used = new boolean[1];
    QueryCachingPolicy policy = new QueryCachingPolicy() {
        @Override// www.  j  a v a  2 s .  com
        public boolean shouldCache(Query query) throws IOException {
            throw new UnsupportedOperationException();
        }

        @Override
        public void onUse(Query query) {
            used[0] = true;
        }
    };
    policy = new ElasticsearchQueryCachingPolicy(policy);
    policy.onUse(new TermQuery(new Term("foo", "bar")));
    assertFalse(used[0]);
    policy.onUse(new PhraseQuery("foo", "bar", "baz"));
    assertTrue(used[0]);
}