[][src]Struct tantivy::Index

pub struct Index { /* fields omitted */ }

Search Index

Methods

impl Index[src]

pub fn exists<Dir: Directory>(dir: &Dir) -> bool[src]

Examines the director to see if it contains an index

pub fn search_executor(&self) -> &Executor[src]

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.

pub fn set_multithread_executor(&mut self, num_threads: usize)[src]

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

pub fn set_default_multithread_executor(&mut self)[src]

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

pub fn create_in_ram(schema: Schema) -> 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.

pub fn create_in_dir<P: AsRef<Path>>(
    directory_path: P,
    schema: Schema
) -> Result<Index>
[src]

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.

pub fn open_or_create<Dir: Directory>(dir: Dir, schema: Schema) -> Result<Index>[src]

Opens or creates a new index in the provided directory

pub fn create_from_tempdir(schema: Schema) -> Result<Index>[src]

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.

pub fn create<Dir: Directory>(dir: Dir, schema: Schema) -> Result<Index>[src]

Creates a new index given an implementation of the trait Directory

pub fn tokenizers(&self) -> &TokenizerManager[src]

Accessor for the tokenizer manager.

pub fn tokenizer_for_field(
    &self,
    field: Field
) -> Result<Box<dyn BoxedTokenizer>>
[src]

Helper to access the tokenizer associated to a specific field.

pub fn reader(&self) -> Result<IndexReader>[src]

Create a default IndexReader for the given index.

See Index.reader_builder().

pub fn reader_builder(&self) -> IndexReaderBuilder[src]

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, over the lifetime of most problem.

pub fn open_in_dir<P: AsRef<Path>>(directory_path: P) -> Result<Index>[src]

Opens a new directory from an index path.

pub fn open<D: Directory>(directory: D) -> Result<Index>[src]

Open the index using the provided directory

pub fn load_metas(&self) -> Result<IndexMeta>[src]

Reads the index meta file from the directory.

pub fn writer_with_num_threads(
    &self,
    num_threads: usize,
    overall_heap_size_in_bytes: usize
) -> Result<IndexWriter>
[src]

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::DirectoryLockBusy or an Error::IOError.

Panics

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

pub fn writer(&self, overall_heap_size_in_bytes: usize) -> Result<IndexWriter>[src]

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.

pub fn schema(&self) -> Schema[src]

Accessor to the index schema

The schema is actually cloned.

pub fn searchable_segments(&self) -> Result<Vec<Segment>>[src]

Returns the list of segments that are searchable

pub fn new_segment(&self) -> Segment[src]

Creates a new segment.

pub fn directory(&self) -> &ManagedDirectory[src]

Return a reference to the index directory.

pub fn directory_mut(&mut self) -> &mut ManagedDirectory[src]

Return a mutable reference to the index directory.

pub fn searchable_segment_metas(&self) -> Result<Vec<SegmentMeta>>[src]

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

pub fn searchable_segment_ids(&self) -> Result<Vec<SegmentId>>[src]

Returns the list of segment ids that are searchable.

Trait Implementations

impl Clone for Index[src]

impl Debug for Index[src]

Auto Trait Implementations

impl Send for Index

impl Sync for Index

impl Unpin for Index

impl !UnwindSafe for Index

impl !RefUnwindSafe for Index

Blanket Implementations

impl<T> Fruit for T where
    T: Send + Downcast
[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Erased for T[src]

impl<T> Downcast for T where
    T: Any
[src]

impl<T> DowncastSync for T where
    T: Send + Sync + Any
[src]