Struct tantivy::schema::Schema [−][src]
pub struct Schema(_);
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 = SchemaBuilder::default(); 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();
Methods
impl Schema
[src]
impl Schema
pub fn get_field_entry(&self, field: Field) -> &FieldEntry
[src]
pub fn get_field_entry(&self, field: Field) -> &FieldEntry
Return the FieldEntry
associated to a Field
.
pub fn get_field_name(&self, field: Field) -> &str
[src]
pub fn get_field_name(&self, field: Field) -> &str
Return the field name for a given Field
.
pub fn fields(&self) -> &[FieldEntry]
[src]
pub fn fields(&self) -> &[FieldEntry]
Return the list of all the Field
s.
pub fn get_field(&self, field_name: &str) -> Option<Field>
[src]
pub fn get_field(&self, field_name: &str) -> Option<Field>
Returns the field options associated with a given name.
Panics
Panics if the field name does not exist. It is meant as an helper for user who created and control the content of their schema.
If panicking is not an option for you,
you may use get(&self, field_name: &str)
.
pub fn to_named_doc(&self, doc: &Document) -> NamedFieldDocument
[src]
pub fn to_named_doc(&self, doc: &Document) -> NamedFieldDocument
Create a named document off the doc.
pub fn to_json(&self, doc: &Document) -> String
[src]
pub fn to_json(&self, doc: &Document) -> String
Encode the schema in JSON.
Encoding a document cannot fail.
pub fn parse_document(
&self,
doc_json: &str
) -> Result<Document, DocParsingError>
[src]
pub fn parse_document(
&self,
doc_json: &str
) -> Result<Document, DocParsingError>
Build a document object from a json-object.
Trait Implementations
impl Clone for Schema
[src]
impl Clone for Schema
fn clone(&self) -> Schema
[src]
fn clone(&self) -> Schema
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl Serialize for Schema
[src]
impl Serialize for Schema
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where
S: Serializer,
[src]
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where
S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl<'de> Deserialize<'de> for Schema
[src]
impl<'de> Deserialize<'de> for Schema
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where
D: Deserializer<'de>,
[src]
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more