Lucene.Net
3.0.3
Lucene.Net is a .NET port of the Java Lucene Indexing Library
|
Implements search over a single IndexReader. More...
Inherits Lucene.Net.Search.Searcher.
Public Member Functions | |
IndexSearcher (Directory path) | |
Creates a searcher searching the index in the named directory, with readOnly=true | |
IndexSearcher (Directory path, bool readOnly) | |
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. | |
IndexSearcher (IndexReader r) | |
Creates a searcher searching the provided index | |
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 | |
override int | DocFreq (Term term) |
Expert: Returns the number of documents containing term . Called by search code to compute term weights. | |
override Document | Doc (int i) |
Expert: Returns the stored fields of document i . | |
override Document | Doc (int i, FieldSelector fieldSelector) |
Get the Lucene.Net.Documents.Documentat the n th position. The Lucene.Net.Documents.FieldSelector may be used to determine what Lucene.Net.Documents.Fields to load and how they should be loaded. | |
override TopDocs | Search (Weight weight, Filter filter, int nDocs) |
Expert: Low-level search implementation. Finds the top n hits for query , applying filter if non-null. | |
override TopFieldDocs | Search (Weight weight, Filter filter, int nDocs, Sort sort) |
Expert: Low-level search implementation with arbitrary sorting. Finds the top n hits for query , applying filter if non-null, and sorting the hits by the criteria in sort . | |
virtual TopFieldDocs | Search (Weight weight, Filter filter, int nDocs, Sort sort, bool fillFields) |
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). | |
override void | Search (Weight weight, Filter filter, Collector collector) |
Lower-level search API. | |
override Query | Rewrite (Query original) |
Expert: called to re-write queries into primitive queries. | |
override Explanation | Explain (Weight weight, int doc) |
Expert: low-level implementation method Returns an Explanation that describes how doc scored against weight . | |
virtual void | SetDefaultFieldSortScoring (bool doTrackScores, bool doMaxScore) |
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 Member Functions inherited from Lucene.Net.Search.Searcher | |
virtual TopFieldDocs | Search (Query query, Filter filter, int n, Sort sort) |
Search implementation with arbitrary sorting. Finds the top n hits for query , applying filter if non-null, and sorting the hits by the criteria in sort . | |
virtual void | Search (Query query, Collector results) |
Lower-level search API. | |
virtual void | Search (Query query, Filter filter, Collector results) |
Lower-level search API. | |
virtual TopDocs | Search (Query query, Filter filter, int n) |
Finds the top n hits for query , applying filter if non-null. | |
virtual TopDocs | Search (Query query, int n) |
Finds the top n hits for query . | |
virtual Explanation | Explain (Query query, int doc) |
Returns an Explanation that describes how doc scored against query . | |
virtual Weight | CreateWeight (Query query) |
creates a weight for query | |
virtual int[] | DocFreqs (Term[] terms) |
Expert: For each term in the terms array, calculates the number of documents containing term . Returns an array with these document frequencies. Used to minimize number of remote calls. | |
void | Close () |
Frees resources associated with this Searcher. Be careful not to call this method while you are still using objects that reference this searchable | |
void | Dispose () |
Protected Member Functions | |
override void | Dispose (bool disposing) |
Protected Member Functions inherited from Lucene.Net.Search.Searcher | |
Searcher () | |
Properties | |
virtual IndexReader | IndexReader [get] |
Return the Index.IndexReader this searches. | |
override int | MaxDoc [get] |
IndexReader | reader_ForNUnit [get] |
Properties inherited from Lucene.Net.Search.Searcher | |
virtual Similarity | Similarity [get, set] |
Expert: Gets or Sets the Similarity implementation used by this Searcher. | |
abstract int | MaxDoc [get] |
Properties inherited from Lucene.Net.Search.Searchable | |
int | MaxDoc [get] |
Expert: Returns one greater than the largest possible document number. Called by search code to compute term weights. | |
Implements search over a single IndexReader.
Applications usually need only call the inherited Searcher.Search(Query,int) or Searcher.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.
Definition at line 47 of file IndexSearcher.cs.
Lucene.Net.Search.IndexSearcher.IndexSearcher | ( | Directory | path | ) |
Creates a searcher searching the index in the named directory, with readOnly=true
<throws>CorruptIndexException if the index is corrupt</throws> <throws>IOException if there is a low-level IO error</throws>
Definition at line 62 of file IndexSearcher.cs.
Lucene.Net.Search.IndexSearcher.IndexSearcher | ( | Directory | path, |
bool | readOnly | ||
) |
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.
<throws> CorruptIndexException if the index is corrupt </throws> <throws> IOException if there is a low-level IO error </throws>
path | directory where IndexReader will be opened |
readOnly | if true, the underlying IndexReader will be opened readOnly |
Definition at line 80 of file IndexSearcher.cs.
Lucene.Net.Search.IndexSearcher.IndexSearcher | ( | IndexReader | r | ) |
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.
Definition at line 92 of file IndexSearcher.cs.
Lucene.Net.Search.IndexSearcher.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
Definition at line 104 of file IndexSearcher.cs.
|
protectedvirtual |
Implements Lucene.Net.Search.Searcher.
Definition at line 140 of file IndexSearcher.cs.
|
virtual |
Expert: Returns the stored fields of document i
.
<throws> CorruptIndexException if the index is corrupt </throws> <throws> IOException if there is a low-level IO error </throws>
Implements Lucene.Net.Search.Searcher.
Definition at line 160 of file IndexSearcher.cs.
|
virtual |
Get the Lucene.Net.Documents.Documentat the n
th position. The Lucene.Net.Documents.FieldSelector may be used to determine what Lucene.Net.Documents.Fields to load and how they should be loaded.
NOTE: If the underlying Reader (more specifically, the underlying FieldsReader
) is closed before the lazy Lucene.Net.Documents.Field is loaded an exception may be thrown. If you want the value of a lazy Lucene.Net.Documents.Field to be available after closing you must explicitly load it or fetch the Document again with a new loader.
n | Get the document at the n th position |
fieldSelector | The Lucene.Net.Documents.FieldSelector to use to determine what Fields should be loaded on the Document. May be null, in which case all Fields will be loaded. |
<throws> CorruptIndexException if the index is corrupt </throws> <throws> IOException if there is a low-level IO error </throws>
Implements Lucene.Net.Search.Searcher.
Definition at line 166 of file IndexSearcher.cs.
|
virtual |
Expert: Returns the number of documents containing term
. Called by search code to compute term weights.
Implements Lucene.Net.Search.Searcher.
Definition at line 154 of file IndexSearcher.cs.
|
virtual |
Expert: low-level implementation method Returns an Explanation that describes how doc
scored against weight
.
This is intended to be used in developing Similarity implementations, and, for good performance, should not be displayed with every hit. Computing an explanation is as expensive as executing the query over the entire index.
Applications should call Searcher.Explain(Query, int).
<throws> BooleanQuery.TooManyClauses </throws>
Implements Lucene.Net.Search.Searcher.
Definition at line 309 of file IndexSearcher.cs.
Expert: called to re-write queries into primitive queries.
<throws> BooleanQuery.TooManyClauses </throws>
Implements Lucene.Net.Search.Searcher.
Definition at line 299 of file IndexSearcher.cs.
|
virtual |
Expert: Low-level search implementation. Finds the top n
hits for query
, applying filter
if non-null.
Applications should usually call Searcher.Search(Query, int) or Searcher.Search(Query,Filter,int) instead.
<throws> BooleanQuery.TooManyClauses </throws>
Implements Lucene.Net.Search.Searcher.
Definition at line 178 of file IndexSearcher.cs.
|
virtual |
Expert: Low-level search implementation with arbitrary sorting. Finds the top n
hits for query
, applying filter
if non-null, and sorting the hits by the criteria in sort
.
Applications should usually call Searcher.Search(Query,Filter,int,Sort) instead.
<throws> BooleanQuery.TooManyClauses </throws>
Implements Lucene.Net.Search.Searcher.
Definition at line 192 of file IndexSearcher.cs.
|
virtual |
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).
Definition at line 207 of file IndexSearcher.cs.
|
virtual |
Lower-level search API.
Collector.Collect(int) is called for every document.
Collector-based access to remote indexes is discouraged.
Applications should only use this if they need all of the matching documents. The high-level search API (Searcher.Search(Query,int)) is usually more efficient, as it skips non-high-scoring hits.
weight | to match documents |
filter | if non-null, used to permit documents to be collected. |
collector | to receive hits |
<throws> BooleanQuery.TooManyClauses </throws>
Implements Lucene.Net.Search.Searcher.
Definition at line 216 of file IndexSearcher.cs.
|
virtual |
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.
doTrackScores | If true, then scores are returned for every matching document in TopFieldDocs. |
doMaxScore | If true, then the max score for all matching docs is computed. |
Definition at line 332 of file IndexSearcher.cs.
|
get |
Return the Index.IndexReader this searches.
Definition at line 136 of file IndexSearcher.cs.
|
get |
Definition at line 173 of file IndexSearcher.cs.
|
get |
Definition at line 339 of file IndexSearcher.cs.