logo
pub struct SchemaBuilder { /* private fields */ }
Expand description

Tantivy has a very strict schema. You need to specify in advance whether a field is indexed or not, stored or not, and RAM-based or not.

This is done by creating a schema object, and setting up the fields one by one. It is for the moment impossible to remove fields.

Examples

use tantivy::schema::*;

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 schema = schema_builder.build();

Implementations

Create a new SchemaBuilder

Adds a new u64 field. Returns the associated field handle

Caution

Appending two fields with the same name will result in the shadowing of the first by the second one. The first field will get a field id but only the second one will be indexed

Adds a new i64 field. Returns the associated field handle

Caution

Appending two fields with the same name will result in the shadowing of the first by the second one. The first field will get a field id but only the second one will be indexed

Adds a new f64 field. Returns the associated field handle

Caution

Appending two fields with the same name will result in the shadowing of the first by the second one. The first field will get a field id but only the second one will be indexed

Adds a new date field. Returns the associated field handle Internally, Tantivy simply stores dates as i64 UTC timestamps, while the user supplies DateTime values for convenience.

Caution

Appending two fields with the same name will result in the shadowing of the first by the second one. The first field will get a field id but only the second one will be indexed

Adds a new text field. Returns the associated field handle

Caution

Appending two fields with the same name will result in the shadowing of the first by the second one. The first field will get a field id but only the second one will be indexed

Adds a facet field to the schema.

Adds a fast bytes field to the schema.

Bytes field are not searchable and are only used as fast field, to associate any kind of payload to a document.

For instance, learning-to-rank often requires to access some document features at scoring time. These can be serializing and stored as a bytes field to get access rapidly when scoring each document.

Adds a json object field to the schema.

Adds a field entry to the schema in build.

Finalize the creation of a Schema This will consume your SchemaBuilder

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.