Struct tantivy::Index [−][src]
pub struct Index { /* fields omitted */ }
Search Index
Methods
impl Index
[src]
impl Index
pub fn create_in_ram(schema: Schema) -> Index
[src]
pub fn create_in_ram(schema: Schema) -> Index
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]
pub fn create_in_dir<P: AsRef<Path>>(
directory_path: P,
schema: Schema
) -> Result<Index>
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 create_from_tempdir(schema: Schema) -> Result<Index>
[src]
pub fn create_from_tempdir(schema: Schema) -> Result<Index>
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]
pub fn create<Dir: Directory>(dir: Dir, schema: Schema) -> Result<Index>
Creates a new index given an implementation of the trait Directory
pub fn tokenizers(&self) -> &TokenizerManager
[src]
pub fn tokenizers(&self) -> &TokenizerManager
Accessor for the tokenizer manager.
pub fn tokenizer_for_field(&self, field: Field) -> Result<Box<BoxedTokenizer>>
[src]
pub fn tokenizer_for_field(&self, field: Field) -> Result<Box<BoxedTokenizer>>
Helper to access the tokenizer associated to a specific field.
pub fn open_in_dir<P: AsRef<Path>>(directory_path: P) -> Result<Index>
[src]
pub fn open_in_dir<P: AsRef<Path>>(directory_path: P) -> Result<Index>
Opens a new directory from an index path.
pub fn open<D: Directory>(directory: D) -> Result<Index>
[src]
pub fn open<D: Directory>(directory: D) -> Result<Index>
Open the index using the provided directory
pub fn load_metas(&self) -> Result<IndexMeta>
[src]
pub fn load_metas(&self) -> Result<IndexMeta>
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]
pub fn writer_with_num_threads(
&self,
num_threads: usize,
overall_heap_size_in_bytes: usize
) -> Result<IndexWriter>
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 ofoverall_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.
pub fn writer(&self, overall_heap_size_in_bytes: usize) -> Result<IndexWriter>
[src]
pub fn writer(&self, overall_heap_size_in_bytes: usize) -> Result<IndexWriter>
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]
pub fn schema(&self) -> Schema
Accessor to the index schema
The schema is actually cloned.
pub fn searchable_segments(&self) -> Result<Vec<Segment>>
[src]
pub fn searchable_segments(&self) -> Result<Vec<Segment>>
Returns the list of segments that are searchable
pub fn new_segment(&self) -> Segment
[src]
pub fn new_segment(&self) -> Segment
Creates a new segment.
pub fn directory(&self) -> &ManagedDirectory
[src]
pub fn directory(&self) -> &ManagedDirectory
Return a reference to the index directory.
pub fn directory_mut(&mut self) -> &mut ManagedDirectory
[src]
pub fn directory_mut(&mut self) -> &mut ManagedDirectory
Return a mutable reference to the index directory.
pub fn searchable_segment_metas(&self) -> Result<Vec<SegmentMeta>>
[src]
pub fn searchable_segment_metas(&self) -> Result<Vec<SegmentMeta>>
Reads the meta.json and returns the list of
SegmentMeta
from the last commit.
pub fn searchable_segment_ids(&self) -> Result<Vec<SegmentId>>
[src]
pub fn searchable_segment_ids(&self) -> Result<Vec<SegmentId>>
Returns the list of segment ids that are searchable.
pub fn set_num_searchers(&mut self, num_searchers: usize)
[src]
pub fn set_num_searchers(&mut self, num_searchers: usize)
Sets the number of searchers to use
Only works after the next call to load_searchers
pub fn load_searchers(&self) -> Result<()>
[src]
pub fn load_searchers(&self) -> Result<()>
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.
pub fn searcher(&self) -> LeasedItem<Searcher>
[src]
pub fn searcher(&self) -> LeasedItem<Searcher>
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]
impl Debug for Index
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl Clone for Index
[src]
impl Clone for Index