Example usage for org.apache.lucene.search QueryCache doCache

List of usage examples for org.apache.lucene.search QueryCache doCache

Introduction

In this page you can find the example usage for org.apache.lucene.search QueryCache doCache.

Prototype

Weight doCache(Weight weight, QueryCachingPolicy policy);

Source Link

Document

Return a wrapper around the provided weight that will cache matching docs per-segment accordingly to the given policy.

Usage

From source file:com.lucene.MyIndexSearcher.java

License:Apache License

public Weight createWeight(Query query, boolean needsScores) throws IOException {
    final QueryCache queryCache = this.queryCache;
    Weight weight = query.createWeight(this, needsScores);
    if (!needsScores && queryCache != null) {
        weight = queryCache.doCache(weight, queryCachingPolicy);
    }/*from w  w w. j av a 2 s .c o  m*/
    return weight;
}