C# Class Lucene.Net.Search.IndexSearcher

Implements search over a single IndexReader.

Applications usually need only call the inherited {@link #Search(Query)} or {@link #Search(Query,Filter)} 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.

Inheritance: Searcher
Mostra file Open project: synhershko/lucene.net Class Usage Examples

Public Methods

Method Description
Doc ( int i ) : Lucene.Net.Documents.Document
Doc ( int i, Lucene.Net.Documents.FieldSelector fieldSelector ) : Lucene.Net.Documents.Document
DocFreq ( Lucene.Net.Index.Term term ) : int
Explain ( Weight weight, int doc ) : Explanation
IndexSearcher ( IndexReader r ) : System

Creates a searcher searching the provided index

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.

IndexSearcher ( IndexReader reader, IndexReader subReaders, int docStarts ) : System

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

IndexSearcher ( Lucene.Net.Store.Directory path ) : System

Creates a searcher searching the index in the named directory, with readOnly=true

IndexSearcher ( Lucene.Net.Store.Directory path, bool readOnly ) : System

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.

Rewrite ( Query original ) : Query
Search ( Weight weight, Filter filter, int nDocs ) : Lucene.Net.Search.TopDocs
Search ( Weight weight, Filter filter, int nDocs, Lucene.Net.Search.Sort sort ) : Lucene.Net.Search.TopFieldDocs
Search ( Weight weight, Filter filter, int nDocs, Lucene.Net.Search.Sort sort, bool fillFields ) : Lucene.Net.Search.TopFieldDocs

Just like Search(Weight, Filter, int, Sort), but you choose whether or not the fields in the returned FieldDoc instances should be set by specifying fillFields.

NOTE: this does not compute scores by default. If you need scores, create a TopFieldCollector instance by calling TopFieldCollector.Create and then pass that to Search(Weight, Filter, Collector).

Search ( Weight weight, Filter filter, Collector collector ) : void
SetDefaultFieldSortScoring ( bool doTrackScores, bool doMaxScore ) : void

By default, no scores are computed when sorting by field (using Searcher.Search(Query,Filter,int,Sort)). You can change that, per IndexSearcher instance, by calling this method. Note that this will incur a CPU cost.

Protected Methods

Method Description
Dispose ( bool disposing ) : void
GatherSubReaders ( System allSubReaders, IndexReader r ) : void

Private Methods

Method Description
IndexSearcher ( IndexReader r, bool closeReader ) : System
SearchWithFilter ( IndexReader reader, Weight weight, Filter filter, Collector collector ) : void

Method Details

Dispose() protected method

protected Dispose ( bool disposing ) : void
disposing bool
return void

Doc() public method

public Doc ( int i ) : Lucene.Net.Documents.Document
i int
return Lucene.Net.Documents.Document

Doc() public method

public Doc ( int i, Lucene.Net.Documents.FieldSelector fieldSelector ) : Lucene.Net.Documents.Document
i int
fieldSelector Lucene.Net.Documents.FieldSelector
return Lucene.Net.Documents.Document

DocFreq() public method

public DocFreq ( Lucene.Net.Index.Term term ) : int
term Lucene.Net.Index.Term
return int

Explain() public method

public Explain ( Weight weight, int doc ) : Explanation
weight Weight
doc int
return Explanation

GatherSubReaders() protected method

protected GatherSubReaders ( System allSubReaders, IndexReader r ) : void
allSubReaders System
r Lucene.Net.Index.IndexReader
return void

IndexSearcher() public method

Creates a searcher searching the provided index

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 IndexSearcher ( IndexReader r ) : System
r Lucene.Net.Index.IndexReader
return System

IndexSearcher() public method

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

public IndexSearcher ( IndexReader reader, IndexReader subReaders, int docStarts ) : System
reader Lucene.Net.Index.IndexReader
subReaders Lucene.Net.Index.IndexReader
docStarts int
return System

IndexSearcher() public method

Creates a searcher searching the index in the named directory, with readOnly=true
public IndexSearcher ( Lucene.Net.Store.Directory path ) : System
path Lucene.Net.Store.Directory
return System

IndexSearcher() public method

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.
public IndexSearcher ( Lucene.Net.Store.Directory path, bool readOnly ) : System
path Lucene.Net.Store.Directory directory where IndexReader will be opened ///
readOnly bool if true, the underlying IndexReader /// will be opened readOnly ///
return System

Rewrite() public method

public Rewrite ( Query original ) : Query
original Query
return Query

Search() public method

public Search ( Weight weight, Filter filter, int nDocs ) : Lucene.Net.Search.TopDocs
weight Weight
filter Filter
nDocs int
return Lucene.Net.Search.TopDocs

Search() public method

public Search ( Weight weight, Filter filter, int nDocs, Lucene.Net.Search.Sort sort ) : Lucene.Net.Search.TopFieldDocs
weight Weight
filter Filter
nDocs int
sort Lucene.Net.Search.Sort
return Lucene.Net.Search.TopFieldDocs

Search() public method

Just like Search(Weight, Filter, int, Sort), but you choose whether or not the fields in the returned FieldDoc instances should be set by specifying fillFields.

NOTE: this does not compute scores by default. If you need scores, create a TopFieldCollector instance by calling TopFieldCollector.Create and then pass that to Search(Weight, Filter, Collector).

public Search ( Weight weight, Filter filter, int nDocs, Lucene.Net.Search.Sort sort, bool fillFields ) : Lucene.Net.Search.TopFieldDocs
weight Weight
filter Filter
nDocs int
sort Lucene.Net.Search.Sort
fillFields bool
return Lucene.Net.Search.TopFieldDocs

Search() public method

public Search ( Weight weight, Filter filter, Collector collector ) : void
weight Weight
filter Filter
collector Collector
return void

SetDefaultFieldSortScoring() public method

By default, no scores are computed when sorting by field (using Searcher.Search(Query,Filter,int,Sort)). You can change that, per IndexSearcher instance, by calling this method. Note that this will incur a CPU cost.
public SetDefaultFieldSortScoring ( bool doTrackScores, bool doMaxScore ) : void
doTrackScores bool If true, then scores are returned for every matching document /// in . /// ///
doMaxScore bool If true, then the max score for all matching docs is computed. ///
return void