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]
impl IndexWriter
pub fn wait_merging_threads(self) -> Result<(), Error>
[src]
pub fn wait_merging_threads(self) -> Result<(), Error>
The index writer
pub fn new_segment(&self) -> Segment
[src]
pub fn new_segment(&self) -> Segment
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>pub fn get_merge_policy(&self) -> Box<MergePolicy>
[src]
pub fn get_merge_policy(&self) -> Box<MergePolicy>
Accessor to the merge policy.
pub fn set_merge_policy(&self, merge_policy: Box<MergePolicy>)
[src]
pub fn set_merge_policy(&self, merge_policy: Box<MergePolicy>)
Set the merge policy.
pub fn garbage_collect_files(&mut self) -> Result<(), Error>
[src]
pub fn garbage_collect_files(&mut self) -> Result<(), Error>
Detects and removes the files that are not used by the index anymore.
pub fn merge(
&mut self,
segment_ids: &[SegmentId]
) -> Result<Receiver<SegmentMeta>, Error>
[src]
pub fn merge(
&mut self,
segment_ids: &[SegmentId]
) -> Result<Receiver<SegmentMeta>, Error>
Merges a given list of segments
segment_ids
is required to be non-empty.
pub fn rollback(&mut self) -> Result<(), Error>
[src]
pub fn rollback(&mut self) -> Result<(), 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.
pub fn prepare_commit(&mut self) -> Result<PreparedCommit, Error>
[src]
pub fn prepare_commit(&mut self) -> Result<PreparedCommit, Error>
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()
pub fn commit(&mut self) -> Result<u64, Error>
[src]
pub 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.
pub fn delete_term(&mut self, term: Term) -> u64
[src]
pub 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()
.
pub fn commit_opstamp(&self) -> u64
[src]
pub 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.
pub fn add_document(&mut self, document: Document) -> u64
[src]
pub 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.
Auto Trait Implementations
impl Send for IndexWriter
impl Send for IndexWriter
impl Sync for IndexWriter
impl Sync for IndexWriter