org.apache.lucene.search

Class IndexSearcher

Implemented Interfaces:
java.rmi.Remote, Searchable

public class IndexSearcher
extends Searcher

Implements search over a single IndexReader.

Applications usually need only call the inherited search(Query) or search(Query,Filter) methods.

Constructor Summary

IndexSearcher(String path)
Creates a searcher searching the index in the named directory.
IndexSearcher(IndexReader r)
Creates a searcher searching the provided index.
IndexSearcher(Directory directory)
Creates a searcher searching the index in the provided directory.

Method Summary

void
close()
Note that the underlying IndexReader is not closed, if IndexSearcher was constructed with IndexSearcher(IndexReader r).
Document
doc(int i)
int
docFreq(Term term)
Explanation
explain(Query query, int doc)
int
maxDoc()
Query
rewrite(Query original)
TopDocs
search(Query query, Filter filter, int nDocs)
TopFieldDocs
search(Query query, Filter filter, int nDocs, Sort sort)
void
search(Query query, Filter filter, HitCollector results)

Methods inherited from class org.apache.lucene.search.Searcher

getSimilarity, search, search, search, search, search, setSimilarity

Constructor Details

IndexSearcher

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

IndexSearcher

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

IndexSearcher

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

Method Details

close

public void close()
            throws IOException
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.
Specified by:
close in interface Searchable

doc

public Document doc(int i)
            throws IOException
Specified by:
doc in interface Searchable

docFreq

public int docFreq(Term term)
            throws IOException
Specified by:
docFreq in interface Searchable

explain

public Explanation explain(Query query,
                           int doc)
            throws IOException
Specified by:
explain in interface Searchable

maxDoc

public int maxDoc()
            throws IOException
Specified by:
maxDoc in interface Searchable

rewrite

public Query rewrite(Query original)
            throws IOException
Specified by:
rewrite in interface Searchable

search

public TopDocs search(Query query,
                      Filter filter,
                      int nDocs)
            throws IOException
Specified by:
search in interface Searchable

search

public TopFieldDocs search(Query query,
                           Filter filter,
                           int nDocs,
                           Sort sort)
            throws IOException
Specified by:
search in interface Searchable

search

public void search(Query query,
                   Filter filter,
                   HitCollector results)
            throws IOException
Specified by:
search in interface Searchable

Copyright © 2000-2007 Apache Software Foundation. All Rights Reserved.