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<(), Error>
The index writer
fn get_merge_policy(&self) -> Box<MergePolicy>
Accessor to the merge policy.
fn set_merge_policy(&self, merge_policy: Box<MergePolicy>)
Set the merge policy.
fn garbage_collect_files(&mut self) -> Result<(), Error>
Detects and removes the files that are not used by the index anymore.
fn merge(
&mut self,
segment_ids: &[SegmentId]
) -> impl Future<Item = SegmentMeta, Error = Canceled>
&mut self,
segment_ids: &[SegmentId]
) -> impl Future<Item = SegmentMeta, Error = Canceled>
Merges a given list of segments
fn rollback(self) -> Result<IndexWriter, Error>
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 opstamp at the last commit is returned.
fn commit(&mut self) -> Result<u64, Error>
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 opstamp
of the last document
that made it in the commit.
fn delete_term(&mut self, term: Term) -> u64
Delete all documents containing a given term.
Delete operation only affects documents that were added in previous commits, and documents that were added previously in the same commit.
Like adds, the deletion itself will be visible
only after calling commit()
.
fn commit_opstamp(&self) -> u64
Returns the opstamp of the last successful commit.
This is, for instance, the opstamp the index will rollback to if there is a failure like a power surge.
This is also the opstamp of the commit that is currently available for searchers.
fn add_document(&mut self, document: Document) -> u64
Adds a document.
If the indexing pipeline is full, this call may block.
The opstamp 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.