Struct tantivy::Index
[−]
[src]
pub struct Index { /* fields omitted */ }
Tantivy's Search Index
Methods
impl Index
[src]
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.
fn create(directory_path: &Path, 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.
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
.
fn from_directory(directory: Box<Directory>, schema: Schema) -> Result<Index>
Opens a new directory from a directory.
fn open(directory_path: &Path) -> Result<Index>
Opens a new directory from an index path.
fn docstamp(&self) -> u64
Returns the index docstamp.
The docstamp is the number of documents that have been added from the beginning of time, and until the moment of the last commit.
fn writer_with_num_threads(&self,
num_threads: usize,
heap_size_in_bytes: usize)
-> Result<IndexWriter>
num_threads: usize,
heap_size_in_bytes: usize)
-> Result<IndexWriter>
Creates a multithreaded writer. Each writer produces an independent segment.
Errors
If the lockfile already exists, returns Error::FileAlreadyExists
.
Panics
If the heap size per thread is too small, panics.
fn writer(&self, heap_size_in_bytes: usize) -> Result<IndexWriter>
Creates a multithreaded writer
It just calls writer_with_num_threads
with the number of cores as num_threads
Errors
If the lockfile already exists, returns Error::FileAlreadyExists
.
Panics
If the heap size per thread is too small, panics.
fn schema(&self) -> Schema
Accessor to the index schema
The schema is actually cloned.
fn searchable_segments(&self) -> Vec<Segment>
Returns the list of segments that are searchable
fn delete_segment(&self, segment_id: SegmentId)
Remove all of the file associated with the segment.
This method cannot fail. If a problem occurs, some files may end up never being removed. The error will only be logged.
fn segment(&self, segment_id: SegmentId) -> Segment
Return a segment object given a segment_id
The segment may or may not exist.
fn directory(&self) -> &Directory
Return a reference to the index directory.
fn directory_mut(&mut self) -> &mut Directory
Return a mutable reference to the index directory.
fn new_segment(&self) -> Segment
Creates a new segment.
fn load_searchers(&self) -> Result<()>
Creates a new generation of searchers after a change of the set of searchable indexes.
This needs to be called when a new segment has been published or after a merge.
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 Clone for Index
[src]
fn clone(&self) -> Index
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more