Struct tantivy::IndexBuilder
source · [−]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, IndexSortByField, Order};
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(Cardinality::SingleValue),
);
let schema = schema_builder.build();
let settings = IndexSettings{
sort_by_field: Some(IndexSortByField{
field: "number".to_string(),
order: Order::Asc
}),
..Default::default()
};
let index = Index::builder().schema(schema).settings(settings).create_in_ram();
Implementations
sourceimpl 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 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 open_or_create<T: Into<Box<dyn Directory>>>(self, dir: T) -> Result<Index>
pub fn open_or_create<T: Into<Box<dyn Directory>>>(self, dir: T) -> Result<Index>
Opens or creates a new index in the provided directory
Trait Implementations
sourceimpl Default for IndexBuilder
impl Default for IndexBuilder
Auto Trait Implementations
impl RefUnwindSafe for IndexBuilder
impl Send for IndexBuilder
impl Sync for IndexBuilder
impl Unpin for IndexBuilder
impl UnwindSafe for IndexBuilder
Blanket Implementations
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstablefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
sourcefn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
Convert
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
. Read moresourcefn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
Convert
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
. Read moresourcefn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s. Read moresourcefn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s. Read moresourceimpl<T> DowncastSync for Twhere
T: Any + Send + Sync,
impl<T> DowncastSync for Twhere
T: Any + Send + Sync,
sourcefn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send + 'static>
fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send + 'static>
Convert
Arc<Trait>
(where Trait: Downcast
) to Arc<Any>
. Arc<Any>
can then be
further downcast
into Arc<ConcreteType>
where ConcreteType
implements Trait
. Read more