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§
Source§impl 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
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
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
Sourcepub fn add_bool_field<T: Into<NumericOptions>>(
&mut self,
field_name_str: &str,
field_options: T,
) -> Field
pub fn add_bool_field<T: Into<NumericOptions>>( &mut self, field_name_str: &str, field_options: T, ) -> Field
Adds a new bool field. Returns the associated field handle
§Panics
Panics when field already exists.
Sourcepub fn add_date_field<T: Into<DateOptions>>(
&mut self,
field_name_str: &str,
field_options: T,
) -> Field
pub fn add_date_field<T: Into<DateOptions>>( &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.
§Panics
Panics when field already exists.
Sourcepub fn add_ip_addr_field<T: Into<IpAddrOptions>>(
&mut self,
field_name_str: &str,
field_options: T,
) -> Field
pub fn add_ip_addr_field<T: Into<IpAddrOptions>>( &mut self, field_name_str: &str, field_options: T, ) -> Field
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
§Panics
Panics when field already exists.
Sourcepub fn add_facet_field(
&mut self,
field_name: &str,
facet_options: impl Into<FacetOptions>,
) -> Field
pub fn add_facet_field( &mut self, field_name: &str, facet_options: impl Into<FacetOptions>, ) -> 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§
Source§impl Debug for SchemaBuilder
impl Debug for SchemaBuilder
Source§impl Default for SchemaBuilder
impl Default for SchemaBuilder
Source§fn default() -> SchemaBuilder
fn default() -> SchemaBuilder
Auto Trait Implementations§
impl Freeze for SchemaBuilder
impl RefUnwindSafe for SchemaBuilder
impl Send for SchemaBuilder
impl Sync for SchemaBuilder
impl Unpin for SchemaBuilder
impl UnwindSafe for SchemaBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
, which can then be
downcast
into Box<dyn ConcreteType>
where ConcreteType
implements Trait
.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
, which can then be further
downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more