Example usage for org.apache.lucene.search IndexSearcher getTopReaderContext

List of usage examples for org.apache.lucene.search IndexSearcher getTopReaderContext

Introduction

In this page you can find the example usage for org.apache.lucene.search IndexSearcher getTopReaderContext.

Prototype


public IndexReaderContext getTopReaderContext() 

Source Link

Document

Returns this searchers the top-level IndexReaderContext .

Usage

From source file:org.sindice.siren.search.node.NodeTermQuery.java

License:Apache License

@Override
public Weight createWeight(final IndexSearcher searcher) throws IOException {
    final IndexReaderContext context = searcher.getTopReaderContext();
    final TermContext termState;
    if (perReaderTermState == null || perReaderTermState.topReaderContext != context) {
        // make TermQuery single-pass if we don't have a PRTS or if the context differs!
        termState = TermContext.build(context, term, true); // cache term lookups!
    } else {/*  w  w w  . j a  v a2s.c  o m*/
        // PRTS was pre-build for this IS
        termState = this.perReaderTermState;
    }

    // we must not ignore the given docFreq - if set use the given value (lie)
    if (docFreq != -1)
        termState.setDocFreq(docFreq);

    return new NodeTermWeight(searcher, termState);
}