logo
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

Creates a new IndexBuilder

Set the settings

Set the schema

Creates a new index using the RAMDirectory.

The index will be allocated in anonymous memory. This should only be used for unit tests.

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 IndexAlreadyExists error.

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.

Opens or creates a new index in the provided directory

Trait Implementations

Returns the “default value” for a type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

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 more

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait. Read more

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s. Read more

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s. Read more

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

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

Drops the object pointed to by the given pointer. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.