Class SearcherManager
Utility class to safely share Index
Use Acquire() to obtain the current searcher, and Release(G) to release it, like this:
IndexSearcher s = manager.Acquire();
try
{
// Do searching, doc retrieval, etc. with s
}
finally
{
manager.Release(s);
// Do not use s after this!
s = null;
}
In addition you should periodically call Maybe
Inherited Members
Namespace: Lucene.Net.Search
Assembly: Lucene.Net.dll
Syntax
public sealed class SearcherManager : ReferenceManager<IndexSearcher>
Constructors
| Improve this Doc View SourceSearcherManager(IndexWriter, Boolean, SearcherFactory)
Creates and returns a new Searcher
Declaration
public SearcherManager(IndexWriter writer, bool applyAllDeletes, SearcherFactory searcherFactory)
Parameters
Type | Name | Description |
---|---|---|
Index |
writer | The Index |
System. |
applyAllDeletes | If |
Searcher |
searcherFactory | An optional Searcher |
SearcherManager(Directory, SearcherFactory)
Creates and returns a new Searcher
Declaration
public SearcherManager(Directory dir, SearcherFactory searcherFactory)
Parameters
Type | Name | Description |
---|---|---|
Directory | dir | The directory to open the Directory |
Searcher |
searcherFactory | An optional Searcher |
Methods
| Improve this Doc View SourceDecRef(IndexSearcher)
Declaration
protected override void DecRef(IndexSearcher reference)
Parameters
Type | Name | Description |
---|---|---|
Index |
reference |
Overrides
GetRefCount(IndexSearcher)
Declaration
protected override int GetRefCount(IndexSearcher reference)
Parameters
Type | Name | Description |
---|---|---|
Index |
reference |
Returns
Type | Description |
---|---|
System. |
Overrides
GetSearcher(SearcherFactory, IndexReader)
Expert: creates a searcher from the provided
Index
Declaration
public static IndexSearcher GetSearcher(SearcherFactory searcherFactory, IndexReader reader)
Parameters
Type | Name | Description |
---|---|---|
Searcher |
searcherFactory | |
Index |
reader |
Returns
Type | Description |
---|---|
Index |
IsSearcherCurrent()
Returns true
if no changes have occured since this searcher
ie. reader was opened, otherwise false
.
Declaration
public bool IsSearcherCurrent()
Returns
Type | Description |
---|---|
System. |
See Also
| Improve this Doc View SourceRefreshIfNeeded(IndexSearcher)
Declaration
protected override IndexSearcher RefreshIfNeeded(IndexSearcher referenceToRefresh)
Parameters
Type | Name | Description |
---|---|---|
Index |
referenceToRefresh |
Returns
Type | Description |
---|---|
Index |
Overrides
TryIncRef(IndexSearcher)
Declaration
protected override bool TryIncRef(IndexSearcher reference)
Parameters
Type | Name | Description |
---|---|---|
Index |
reference |
Returns
Type | Description |
---|---|
System. |