Struct tantivy::Index[][src]

pub struct Index { /* fields omitted */ }

Search Index

Methods

impl Index
[src]

Creates a new index using the RAMDirectory.

The index will be allocated in anonymous memory. This should only be used for unit tests.

Creates a new index in a given filepath. The index will use the MMapDirectory.

If a previous index was in this directory, then its meta file will be destroyed.

Creates a new index in a temp directory.

The index will use the MMapDirectory in a newly created directory. The temp directory will be destroyed automatically when the Index object is destroyed.

The temp directory is only used for testing the MmapDirectory. For other unit tests, prefer the RAMDirectory, see: create_in_ram.

Creates a new index given an implementation of the trait Directory

Accessor for the tokenizer manager.

Helper to access the tokenizer associated to a specific field.

Opens a new directory from an index path.

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_heap_size_in_bytes sets the amount of memory allocated for all indexing thread. Each thread will receive a budget of overall_heap_size_in_bytes / num_threads.

Errors

If the lockfile already exists, returns Error::FileAlreadyExists.

Panics

If the heap size per thread is too small, panics.

Creates a multithreaded writer

Tantivy will automatically define the number of threads to use. overall_heap_size_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.

Panics

If the heap size per thread is too small, panics.

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.

Sets the number of searchers to use

Only works after the next call to load_searchers

Update searchers so that they reflect the state of the last .commit().

If indexing happens in the same process as searching, you most likely want to call .load_searchers() right after each successful call to .commit().

If indexing and searching happen in different processes, the way to get the freshest index at all time, is to watch meta.json and call load_searchers whenever a changes happen.

Returns a searcher

This method should be called every single time a search query is performed. The searchers are taken from a pool of num_searchers searchers. If no searcher is available this may block.

The same searcher must be used for a given query, as it ensures the use of a consistent segment set.

Trait Implementations

impl Debug for Index
[src]

Formats the value using the given formatter. Read more

impl Clone for Index
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Auto Trait Implementations

impl Send for Index

impl Sync for Index