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 independent Segment, via a SegmentWriter object.

Methods

impl IndexWriter
[src]

The index writer

Experimental & Advanced API Creates a new segment. and marks it as currently in write.

This method is useful only for users trying to do complex operations, like converting an index format to another.

Important traits for Box<R>

Accessor to the merge policy.

Set the merge policy.

Detects and removes the files that are not used by the index anymore.

Merges a given list of segments

segment_ids is required to be non-empty.

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.

Prepares a commit.

Calling prepare_commit() will cut the indexing queue. All pending documents will be sent to the indexing workers. They will then terminate, regardless of the size of their current segment and flush their work on disk.

Once a commit is "prepared", you can either call

  • .commit(): to accept this commit
  • .abort(): to cancel this commit.

In the current implementation, PreparedCommit borrows the IndexWriter mutably so we are guaranteed that no new document can be added as long as it is committed or is dropped.

It is also possible to add a payload to the commit using this API. See PreparedCommit::set_payload()

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.

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().

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.

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.

Auto Trait Implementations

impl Send for IndexWriter

impl Sync for IndexWriter