pub struct IndexBuilder { /* private fields */ }Expand description
IndexBuilder can be used to create an index.
Use in conjunction with SchemaBuilder.
Global index settings can be configured with IndexSettings.
§Examples
use tantivy::schema::*;
use tantivy::{Index, IndexSettings};
let mut schema_builder = Schema::builder();
let id_field = schema_builder.add_text_field("id", STRING);
let title_field = schema_builder.add_text_field("title", TEXT);
let body_field = schema_builder.add_text_field("body", TEXT);
let number_field = schema_builder.add_u64_field(
"number",
NumericOptions::default().set_fast(),
);
let schema = schema_builder.build();
let settings = IndexSettings{
docstore_blocksize: 100_000,
..Default::default()
};
let index = Index::builder().schema(schema).settings(settings).create_in_ram();Implementations§
Source§impl IndexBuilder
impl IndexBuilder
Sourcepub fn settings(self, settings: IndexSettings) -> Self
pub fn settings(self, settings: IndexSettings) -> Self
Set the settings
Sourcepub fn tokenizers(self, tokenizers: TokenizerManager) -> Self
pub fn tokenizers(self, tokenizers: TokenizerManager) -> Self
Set the tokenizers.
Sourcepub fn fast_field_tokenizers(self, tokenizers: TokenizerManager) -> Self
pub fn fast_field_tokenizers(self, tokenizers: TokenizerManager) -> Self
Set the fast field tokenizers.
Sourcepub fn create_in_ram(self) -> Result<Index, TantivyError>
pub fn create_in_ram(self) -> Result<Index, TantivyError>
Creates a new index using the RamDirectory.
The index will be allocated in anonymous memory. This is useful for indexing small set of documents for instances like unit test or temporary in memory index.
Sourcepub fn create_in_dir<P: AsRef<Path>>(self, directory_path: P) -> Result<Index>
pub fn create_in_dir<P: AsRef<Path>>(self, directory_path: P) -> Result<Index>
Creates a new index in a given filepath.
The index will use the MmapDirectory.
If a previous index was in this directory, it returns an
TantivyError::IndexAlreadyExists error.
Sourcepub fn create_from_tempdir(self) -> Result<Index>
pub fn create_from_tempdir(self) -> 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:
IndexBuilder::create_in_ram().
Trait Implementations§
Auto Trait Implementations§
impl Freeze for IndexBuilder
impl RefUnwindSafe for IndexBuilder
impl Send for IndexBuilder
impl Sync for IndexBuilder
impl Unpin for IndexBuilder
impl UnsafeUnpin for IndexBuilder
impl UnwindSafe for IndexBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
impl<T> Fruit for T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more