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
Afficher le fichier Open project: synhershko/lucene.net Class Usage Examples

Méthodes publiques

Méthode 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.

Méthodes protégées

Méthode Description
Dispose ( bool disposing ) : void
GatherSubReaders ( System allSubReaders, IndexReader r ) : void

Private Methods

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

Method Details

Dispose() protected méthode

protected Dispose ( bool disposing ) : void
disposing bool
Résultat void

Doc() public méthode

public Doc ( int i ) : Lucene.Net.Documents.Document
i int
Résultat Lucene.Net.Documents.Document

Doc() public méthode

public Doc ( int i, Lucene.Net.Documents.FieldSelector fieldSelector ) : Lucene.Net.Documents.Document
i int
fieldSelector Lucene.Net.Documents.FieldSelector
Résultat Lucene.Net.Documents.Document

DocFreq() public méthode

public DocFreq ( Lucene.Net.Index.Term term ) : int
term Lucene.Net.Index.Term
Résultat int

Explain() public méthode

public Explain ( Weight weight, int doc ) : Explanation
weight Weight
doc int
Résultat Explanation

GatherSubReaders() protected méthode

protected GatherSubReaders ( System allSubReaders, IndexReader r ) : void
allSubReaders System
r Lucene.Net.Index.IndexReader
Résultat void

IndexSearcher() public méthode

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
Résultat System

IndexSearcher() public méthode

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
Résultat System

IndexSearcher() public méthode

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
Résultat System

IndexSearcher() public méthode

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 ///
Résultat System

Rewrite() public méthode

public Rewrite ( Query original ) : Query
original Query
Résultat Query

Search() public méthode

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

Search() public méthode

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
Résultat Lucene.Net.Search.TopFieldDocs

Search() public méthode

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
Résultat Lucene.Net.Search.TopFieldDocs

Search() public méthode

public Search ( Weight weight, Filter filter, Collector collector ) : void
weight Weight
filter Filter
collector Collector
Résultat void

SetDefaultFieldSortScoring() public méthode

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. ///
Résultat void