org.apache.lucene.search

Class IndexSearcher

public class IndexSearcher extends Searcher

Implements search over a single IndexReader.

Applications usually need only call the inherited IndexSearcher or IndexSearcher methods. For performance reasons it is recommended to open only one IndexSearcher and use it for all of your searches.

Note that you can only access Hits from an IndexSearcher as long as it is not yet closed, otherwise an IOException will be thrown.

Constructor Summary
IndexSearcher(String path)
Creates a searcher searching the index in the named directory.
IndexSearcher(Directory directory)
Creates a searcher searching the index in the provided directory.
IndexSearcher(IndexReader r)
Creates a searcher searching the provided index.
Method Summary
voidclose()
Note that the underlying IndexReader is not closed, if IndexSearcher was constructed with IndexSearcher(IndexReader r).
Documentdoc(int i)
Documentdoc(int i, FieldSelector fieldSelector)
intdocFreq(Term term)
Explanationexplain(Weight weight, int doc)
IndexReadergetIndexReader()
Return the IndexReader this searches.
intmaxDoc()
Queryrewrite(Query original)
TopDocssearch(Weight weight, Filter filter, int nDocs)
TopFieldDocssearch(Weight weight, Filter filter, int nDocs, Sort sort)
voidsearch(Weight weight, Filter filter, HitCollector results)

Constructor Detail

IndexSearcher

public IndexSearcher(String path)
Creates a searcher searching the index in the named directory.

Throws: CorruptIndexException if the index is corrupt IOException if there is a low-level IO error

IndexSearcher

public IndexSearcher(Directory directory)
Creates a searcher searching the index in the provided directory.

Throws: CorruptIndexException if the index is corrupt IOException if there is a low-level IO error

IndexSearcher

public IndexSearcher(IndexReader r)
Creates a searcher searching the provided index.

Method Detail

close

public void close()
Note that the underlying IndexReader is not closed, if IndexSearcher was constructed with IndexSearcher(IndexReader r). If the IndexReader was supplied implicitly by specifying a directory, then the IndexReader gets closed.

doc

public Document doc(int i)

doc

public Document doc(int i, FieldSelector fieldSelector)

docFreq

public int docFreq(Term term)

explain

public Explanation explain(Weight weight, int doc)

getIndexReader

public IndexReader getIndexReader()
Return the IndexReader this searches.

maxDoc

public int maxDoc()

rewrite

public Query rewrite(Query original)

search

public TopDocs search(Weight weight, Filter filter, int nDocs)

search

public TopFieldDocs search(Weight weight, Filter filter, int nDocs, Sort sort)

search

public void search(Weight weight, Filter filter, HitCollector results)
Copyright © 2000-2007 Apache Software Foundation. All Rights Reserved.