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]
fn get_field_entry(&self, field: Field) -> &FieldEntry
Return the FieldEntry
associated to a Field
.
fn get_field_name(&self, field: Field) -> &str
Return the field name for a given Field
.
fn fields(&self) -> &[FieldEntry]
Return the list of all the Field
s.
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)
.
fn to_named_doc(&self, doc: &Document) -> NamedFieldDocument
Create a named document off the doc.
fn to_json(&self, doc: &Document) -> String
Encode the schema in JSON.
Encoding a document cannot fail.
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]
fn clone(&self) -> Schema
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl Debug for Schema
[src]
impl Serialize for Schema
[src]
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where
S: Serializer,
S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl<'de> Deserialize<'de> for Schema
[src]
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where
D: Deserializer<'de>,
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl From<SchemaBuilder> for Schema
[src]
fn from(schema_builder: SchemaBuilder) -> Schema
Performs the conversion.