pub struct Index { /* private fields */ }
Expand description

Search Index

Implementations

Creates a new builder.

Examines the directory to see if it contains an index.

Effectively, it only checks for the presence of the meta.json file.

Accessor to the search executor.

This pool is used by default when calling searcher.search(...) to perform search on the individual segments.

By default the executor is single thread, and simply runs in the calling thread.

Replace the default single thread search executor pool by a thread pool with a given number of threads.

Replace the default single thread search executor pool by a thread pool with as many threads as there are CPUs on the system.

Creates a new index using the RamDirectory.

The index will be allocated in anonymous memory. This is useful for indexing small set of documents for instances like unit test or temporary in memory index.

Opens or creates a new index in the provided directory

Creates a new index given an implementation of the trait Directory.

If a directory previously existed, it will be erased.

Setter for the tokenizer manager.

Accessor for the tokenizer manager.

Get the tokenizer associated with a specific field.

Create a default IndexReader for the given index.

See [Index.reader_builder()].

Create a IndexReader for the given index.

Most project should create at most one reader for a given index. This method is typically called only once per Index instance.

Creates a new segment_meta (Advanced user only).

As long as the SegmentMeta lives, the files associated with the SegmentMeta are guaranteed to not be garbage collected, regardless of whether the segment is recorded as part of the index or not.

Open the index using the provided directory

Reads the index meta file from the directory.

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 defines the number of indexing workers that should work at the same time.

  • overall_memory_arena_in_bytes sets the amount of memory allocated for all indexing thread. Each thread will receive a budget of overall_memory_arena_in_bytes / num_threads.

Errors

If the lockfile already exists, returns Error::DirectoryLockBusy or an Error::IoError. If the memory arena per thread is too small or too big, returns TantivyError::InvalidArgument

Creates a multithreaded writer

Tantivy will automatically define the number of threads to use, but no more than 8 threads. overall_memory_arena_in_bytes is the total target memory usage that will be split between a given number of threads.

Errors

If the lockfile already exists, returns Error::FileAlreadyExists. If the memory arena per thread is too small or too big, returns TantivyError::InvalidArgument

Accessor to the index settings

Accessor to the index settings

Accessor to the index schema

The schema is actually cloned.

Returns the list of segments that are searchable

Creates a new segment.

Return a reference to the index directory.

Return a mutable reference to the index directory.

Reads the meta.json and returns the list of SegmentMeta from the last commit.

Returns the list of segment ids that are searchable.

Returns the set of corrupted files

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait. Read more
Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait. Read more
Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s. Read more
Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s. Read more
Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

The alignment of pointer.
The type for initializers.
Initializes a with the given initializer. Read more
Dereferences the given pointer. Read more
Mutably dereferences the given pointer. Read more
Drops the object pointed to by the given pointer. Read more
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.