Struct tantivy::IndexWriter
[−]
[src]
pub struct IndexWriter { /* fields omitted */ }
IndexWriter
is the user entry-point to add document to an index.
It manages a small number of indexing thread, as well as a shared
indexing queue.
Each indexing thread builds its own independant Segment
, via
a SegmentWriter
object.
Methods
impl IndexWriter
[src]
fn wait_merging_threads(self) -> Result<()>
The index writer
fn open(index: &Index,
num_threads: usize,
heap_size_in_bytes_per_thread: usize)
-> Result<IndexWriter>
num_threads: usize,
heap_size_in_bytes_per_thread: usize)
-> Result<IndexWriter>
Open a new index writer. Attempts to acquire a lockfile.
The lockfile should be deleted on drop, but it is possible
that due to a panic or other error, a stale lockfile will be
left in the index directory. If you are sure that no other
IndexWriter
on the system is accessing the index directory,
it is safe to manually delete the lockfile.
num_threads specifies the number of indexing workers that should work at the same time.
Errors
If the lockfile already exists, returns Error::FileAlreadyExists
.
Panics
If the heap size per thread is too small, panics.
fn get_merge_policy(&self) -> Box<MergePolicy>
Returns a clone of the index_writer merge policy.
fn set_merge_policy(&self, merge_policy: Box<MergePolicy>)
Set the merge policy.
fn merge(&mut self, segments: &[Segment]) -> Result<()>
Merges a given list of segments
fn rollback(&mut self) -> Result<u64>
Rollback to the last commit
This cancels all of the update that happened before after the last commit. After calling rollback, the index is in the same state as it was after the last commit.
The docstamp at the last commit is returned.
fn commit(&mut self) -> Result<u64>
Commits all of the pending changes
A call to commit blocks. After it returns, all of the document that were added since the last commit are published and persisted.
In case of a crash or an hardware failure (as long as the hard disk is spared), it will be possible to resume indexing from this point.
Commit returns the docstamp
of the last document
that made it in the commit.
fn add_document(&mut self, doc: Document) -> Result<u64>
Adds a document.
If the indexing pipeline is full, this call may block.
The docstamp is an increasing u64
that can
be used by the client to align commits with its own
document queue.
Currently it represents the number of documents that have been added since the creation of the index.