Struct tantivy::schema::SchemaBuilder
source · [−]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
sourceimpl SchemaBuilder
impl SchemaBuilder
sourcepub fn new() -> SchemaBuilder
pub fn new() -> SchemaBuilder
Create a new SchemaBuilder
sourcepub fn add_u64_field<T: Into<NumericOptions>>(
&mut self,
field_name_str: &str,
field_options: T
) -> Field
pub fn add_u64_field<T: Into<NumericOptions>>(
&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
sourcepub fn add_i64_field<T: Into<NumericOptions>>(
&mut self,
field_name_str: &str,
field_options: T
) -> Field
pub fn add_i64_field<T: Into<NumericOptions>>(
&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
sourcepub fn add_f64_field<T: Into<NumericOptions>>(
&mut self,
field_name_str: &str,
field_options: T
) -> Field
pub fn add_f64_field<T: Into<NumericOptions>>(
&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
sourcepub fn add_date_field<T: Into<NumericOptions>>(
&mut self,
field_name_str: &str,
field_options: T
) -> Field
pub fn add_date_field<T: Into<NumericOptions>>(
&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
sourcepub 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
sourcepub 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.
sourcepub 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.
sourcepub fn add_json_field<T: Into<JsonObjectOptions>>(
&mut self,
field_name: &str,
field_options: T
) -> Field
pub fn add_json_field<T: Into<JsonObjectOptions>>(
&mut self,
field_name: &str,
field_options: T
) -> Field
Adds a json object field to the schema.
sourcepub fn add_field(&mut self, field_entry: FieldEntry) -> Field
pub fn add_field(&mut self, field_entry: FieldEntry) -> Field
Adds a field entry to the schema in build.
Trait Implementations
sourceimpl Default for SchemaBuilder
impl Default for SchemaBuilder
sourcefn default() -> SchemaBuilder
fn default() -> SchemaBuilder
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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn 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 T where
T: Any,
impl<T> Downcast for T where
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 more
sourcefn 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 more
sourcefn 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 more
sourcefn 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 more