Class SearchIndex
- Namespace
- TantivyDotNet
- Assembly
- TantivyDotNet.dll
A Tantivy index, in memory or in a directory. Create documents with CreateWriter(IndexWriterOptions) and query them with CreateSearcher().
public sealed class SearchIndex : IDisposable
- Inheritance
-
SearchIndex
- Implements
- Inherited Members
Remarks
This type is thread-safe. Disposing it doesn't invalidate writers or searchers already created from it; each of those must be disposed separately.
Properties
- Schema
The index's schema.
- Settings
The settings the index was created with.
Methods
- Analyze(string, string)
Runs
textthrough a tokenizer of this index and returns the resulting terms, to check what a field indexes or how query text is analyzed.
- Create(string, Schema, IndexSettings?)
Creates a new index in
directory, creating the directory if needed.
- CreateInRam(Schema, IndexSettings?)
Creates an index held entirely in memory. It disappears when disposed.
- CreateSearcher()
Creates a searcher over the latest committed state of the index. The searcher is a snapshot: commits made after this call aren't visible to it, so create a new searcher to see them. To share one snapshot across requests and refresh it after commits, use CreateSearcherManager(SearcherManagerOptions?).
- CreateSearcherManager(SearcherManagerOptions?)
Creates a SearcherManager, which shares one searcher across requests and replaces it when the index changes. Dispose it when done.
- CreateWriter(long, int?)
Creates the index's writer. Only one writer can exist per index at a time; dispose the previous one first.
- CreateWriter(IndexWriterOptions)
Creates the index's writer with
options. Only one writer can exist per index at a time; dispose the previous one first.
- Dispose()
Releases the native index. Safe to call more than once.
- GetStats()
Statistics of the latest commit: segments, documents and sizes. Shorthand for GetStats() on a new searcher.
- Open(string)
Opens an existing index directory. Custom analyzers saved with the index are restored.