Struct tantivy::Index
[−]
[src]
pub struct Index { /* fields omitted */ }
Search Index
Methods
impl Index
[src]
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<P: AsRef<Path>>(
directory_path: P,
schema: Schema
) -> Result<Index>
[src]
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 tokenizers(&self) -> &TokenizerManager
[src]
Accessor for the tokenizer manager.
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 from_directory(
directory: ManagedDirectory,
schema: Schema
) -> Result<Index>
[src]
directory: ManagedDirectory,
schema: Schema
) -> Result<Index>
Create a new index from a directory.
pub fn open<P: AsRef<Path>>(directory_path: P) -> Result<Index>
[src]
Opens a new directory from an index path.
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,
heap_size_in_bytes: usize
) -> Result<IndexWriter>
[src]
&self,
num_threads: usize,
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 specifies the number of indexing workers that should work at the same time.
Errors
If the lockfile already exists, returns Error::FileAlreadyExists
.
Panics
If the heap size per thread is too small, panics.
pub fn writer(&self, heap_size_in_bytes: usize) -> Result<IndexWriter>
[src]
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.
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.
pub fn load_searchers(&self) -> Result<()>
[src]
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.
pub fn searcher(&self) -> LeasedItem<Searcher>
[src]
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]
fn fmt(&self, f: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more