Struct tantivy::schema::SchemaBuilder [−][src]
pub struct SchemaBuilder { /* fields omitted */ }
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
pub fn add_u64_field<T: Into<IntOptions>>(
&mut self,
field_name_str: &str,
field_options: T
) -> Field
pub fn add_u64_field<T: Into<IntOptions>>(
&mut self,
field_name_str: &str,
field_options: T
) -> Field
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
pub fn add_i64_field<T: Into<IntOptions>>(
&mut self,
field_name_str: &str,
field_options: T
) -> Field
pub fn add_i64_field<T: Into<IntOptions>>(
&mut self,
field_name_str: &str,
field_options: T
) -> Field
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
pub fn add_f64_field<T: Into<IntOptions>>(
&mut self,
field_name_str: &str,
field_options: T
) -> Field
pub fn add_f64_field<T: Into<IntOptions>>(
&mut self,
field_name_str: &str,
field_options: T
) -> Field
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
pub fn add_date_field<T: Into<IntOptions>>(
&mut self,
field_name_str: &str,
field_options: T
) -> Field
pub fn add_date_field<T: Into<IntOptions>>(
&mut self,
field_name_str: &str,
field_options: T
) -> Field
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
pub fn add_text_field<T: Into<TextOptions>>(
&mut self,
field_name_str: &str,
field_options: T
) -> Field
pub fn add_text_field<T: Into<TextOptions>>(
&mut self,
field_name_str: &str,
field_options: T
) -> Field
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
pub fn add_facet_field<T: Into<FacetOptions>>(
&mut self,
field_name: &str,
facet_options: T
) -> Field
pub fn add_facet_field<T: Into<FacetOptions>>(
&mut self,
field_name: &str,
facet_options: T
) -> Field
Adds a facet field to the schema.
pub fn add_bytes_field<T: Into<BytesOptions>>(
&mut self,
field_name: &str,
field_options: T
) -> Field
pub fn add_bytes_field<T: Into<BytesOptions>>(
&mut self,
field_name: &str,
field_options: T
) -> Field
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 field entry to the schema in build.
Trait Implementations
Returns the “default value” for a type. Read more
Auto Trait Implementations
impl RefUnwindSafe for SchemaBuilder
impl Send for SchemaBuilder
impl Sync for SchemaBuilder
impl Unpin for SchemaBuilder
impl UnwindSafe for SchemaBuilder
Blanket Implementations
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