Home » lucene-3.0.1-src » org.apache » lucene » search » [javadoc | source]
org.apache.lucene.search
public class: IndexSearcher [javadoc | source]
java.lang.Object
   org.apache.lucene.search.Searcher
      org.apache.lucene.search.IndexSearcher

All Implemented Interfaces:
    Searchable

Implements search over a single IndexReader.

Applications usually need only call the inherited #search(Query,int) or #search(Query,Filter,int) methods. For performance reasons it is recommended to open only one IndexSearcher and use it for all of your searches.

NOTE: IndexSearcher instances are completely thread safe, meaning multiple threads can call any of its methods, concurrently. If your application requires external synchronization, you should not synchronize on the IndexSearcher instance; use your own (non-Lucene) objects instead.

Field Summary
 IndexReader reader     
protected  IndexReader[] subReaders     
protected  int[] docStarts     
Constructor:
 public IndexSearcher(Directory path) throws CorruptIndexException, IOException 
    Creates a searcher searching the index in the named directory, with readOnly=true
    Parameters:
    path - directory where IndexReader will be opened
    Throws:
    CorruptIndexException - if the index is corrupt
    IOException - if there is a low-level IO error
 public IndexSearcher(IndexReader r) 
    Creates a searcher searching the provided index.
 public IndexSearcher(Directory path,
    boolean readOnly) throws CorruptIndexException, IOException 
    Creates a searcher searching the index in the named directory. You should pass readOnly=true, since it gives much better concurrent performance, unless you intend to do write operations (delete documents or change norms) with the underlying IndexReader.
    Parameters:
    path - directory where IndexReader will be opened
    readOnly - if true, the underlying IndexReader will be opened readOnly
    Throws:
    CorruptIndexException - if the index is corrupt
    IOException - if there is a low-level IO error
 public IndexSearcher(IndexReader reader,
    IndexReader[] subReaders,
    int[] docStarts) 
    Expert: directly specify the reader, subReaders and their docID starts.

    NOTE: This API is experimental and might change in incompatible ways in the next release.

Method from org.apache.lucene.search.IndexSearcher Summary:
close,   doc,   doc,   docFreq,   explain,   gatherSubReaders,   getIndexReader,   maxDoc,   rewrite,   search,   search,   search,   search,   setDefaultFieldSortScoring
Methods from org.apache.lucene.search.Searcher:
close,   createWeight,   doc,   doc,   docFreq,   docFreqs,   explain,   explain,   getSimilarity,   maxDoc,   rewrite,   search,   search,   search,   search,   search,   search,   search,   search,   setSimilarity
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.apache.lucene.search.IndexSearcher Detail:
 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.
 public Document doc(int i) throws CorruptIndexException, IOException 
 public Document doc(int i,
    FieldSelector fieldSelector) throws CorruptIndexException, IOException 
 public int docFreq(Term term) throws IOException 
 public Explanation explain(Weight weight,
    int doc) throws IOException 
 protected  void gatherSubReaders(List<IndexReader> allSubReaders,
    IndexReader r) 
 public IndexReader getIndexReader() 
 public int maxDoc() throws IOException 
 public Query rewrite(Query original) throws IOException 
 public TopDocs search(Weight weight,
    Filter filter,
    int nDocs) throws IOException 
 public  void search(Weight weight,
    Filter filter,
    Collector collector) throws IOException 
 public TopFieldDocs search(Weight weight,
    Filter filter,
    int nDocs,
    Sort sort) throws IOException 
 public TopFieldDocs search(Weight weight,
    Filter filter,
    int nDocs,
    Sort sort,
    boolean fillFields) throws IOException 
 public  void setDefaultFieldSortScoring(boolean doTrackScores,
    boolean doMaxScore) 
    By default, no scores are computed when sorting by field (using #search(Query,Filter,int,Sort) ). You can change that, per IndexSearcher instance, by calling this method. Note that this will incur a CPU cost.