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]
pub fn get_field_entry(&self, field: Field) -> &FieldEntry
[src]
Return the FieldEntry
associated to a Field
.
pub fn get_field_name(&self, field: Field) -> &str
[src]
Return the field name for a given Field
.
pub fn fields(&self) -> &[FieldEntry]
[src]
Return the list of all the Field
s.
pub fn get_field(&self, field_name: &str) -> Option<Field>
[src]
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]
Create a named document off the doc.
pub fn to_json(&self, doc: &Document) -> String
[src]
Encode the schema in JSON.
Encoding a document cannot fail.
pub fn parse_document(
&self,
doc_json: &str
) -> Result<Document, DocParsingError>
[src]
&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
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl Debug for Schema
[src]
fn fmt(&self, f: &mut Formatter) -> Result<(), Error>
[src]
Formats the value using the given formatter. Read more
impl Serialize for Schema
[src]
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where
S: Serializer,
[src]
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>,
[src]
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
[src]
Performs the conversion.