pub struct IndexWriter<D: DirectoryWriter> { /* private fields */ }Expand description
Async IndexWriter for adding documents and committing segments
Internally manages parallel segment building based on num_indexing_threads config.
Documents are distributed across multiple segment builders round-robin style.
Implementations§
Source§impl<D: DirectoryWriter> IndexWriter<D>
impl<D: DirectoryWriter> IndexWriter<D>
Sourcepub async fn create(
directory: D,
schema: Schema,
config: IndexConfig,
) -> Result<Self>
pub async fn create( directory: D, schema: Schema, config: IndexConfig, ) -> Result<Self>
Create a new index in the directory
Sourcepub async fn open(directory: D, config: IndexConfig) -> Result<Self>
pub async fn open(directory: D, config: IndexConfig) -> Result<Self>
Open an existing index for writing
Sourcepub fn set_tokenizer<T: Tokenizer>(&mut self, field: Field, tokenizer: T)
pub fn set_tokenizer<T: Tokenizer>(&mut self, field: Field, tokenizer: T)
Set tokenizer for a field
Sourcepub async fn add_document(&self, doc: Document) -> Result<DocId>
pub async fn add_document(&self, doc: Document) -> Result<DocId>
Add a document
Documents are distributed across internal segment builders based on
num_indexing_threads config. When any builder reaches max_docs_per_segment,
it is committed to disk in the background.
Sourcepub async fn commit(&self) -> Result<()>
pub async fn commit(&self) -> Result<()>
Commit all pending segments to disk
Commits all internal segment builders in parallel.
Sourcepub async fn force_merge(&self) -> Result<()>
pub async fn force_merge(&self) -> Result<()>
Force merge all segments into one
Auto Trait Implementations§
impl<D> !Freeze for IndexWriter<D>
impl<D> !RefUnwindSafe for IndexWriter<D>
impl<D> Send for IndexWriter<D>
impl<D> Sync for IndexWriter<D>
impl<D> Unpin for IndexWriter<D>
impl<D> !UnwindSafe for IndexWriter<D>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more