pub struct SurferSchema { /* private fields */ }
Implementations§
Source§impl SurferSchema
impl SurferSchema
pub fn new( schema: Schema, mappings: HashMap<String, SurferFieldTypes>, track_tf: bool, track_tf_idf: bool, ) -> Self
pub fn resolve_mapping(&self) -> &HashMap<String, SurferFieldTypes>
Methods from Deref<Target = Schema>§
Sourcepub fn get_field_entry(&self, field: Field) -> &FieldEntry
pub fn get_field_entry(&self, field: Field) -> &FieldEntry
Return the FieldEntry
associated to a Field
.
Sourcepub fn get_field_name(&self, field: Field) -> &str
pub fn get_field_name(&self, field: Field) -> &str
Return the field name for a given Field
.
Sourcepub fn fields(&self) -> impl Iterator<Item = (Field, &FieldEntry)>
pub fn fields(&self) -> impl Iterator<Item = (Field, &FieldEntry)>
Return the list of all the Field
s.
Sourcepub fn get_field(&self, field_name: &str) -> Option<Field>
pub fn get_field(&self, field_name: &str) -> Option<Field>
Returns the field option associated with a given name.
Sourcepub fn convert_named_doc(
&self,
named_doc: NamedFieldDocument,
) -> Result<Document, DocParsingError>
pub fn convert_named_doc( &self, named_doc: NamedFieldDocument, ) -> Result<Document, DocParsingError>
Create a named document off the doc.
Sourcepub fn to_named_doc(&self, doc: &Document) -> NamedFieldDocument
pub fn to_named_doc(&self, doc: &Document) -> NamedFieldDocument
Create a named document off the doc.
Sourcepub fn to_json(&self, doc: &Document) -> String
pub fn to_json(&self, doc: &Document) -> String
Encode the schema in JSON.
Encoding a document cannot fail.
Sourcepub fn parse_document(
&self,
doc_json: &str,
) -> Result<Document, DocParsingError>
pub fn parse_document( &self, doc_json: &str, ) -> Result<Document, DocParsingError>
Build a document object from a json-object.
Examples found in repository?
examples/04_binary_data.rs (line 47)
25fn main() {
26 println!("This example is here to demonstrate that Tantivy does not support stored bytes yet");
27 // Build Container
28 let data = Container::default();
29 let value = serde_value::to_value(data).expect("[Cough]");
30 let json_doc = serde_json::to_string(&value).expect("[Cough Again]");
31 println!("Json: {}", json_doc);
32
33 // Build Schema
34 let mut builder = Schema::builder();
35 // Is there any alternate way or just not supported?
36 // src/schema/field_type.rs:32 - FieldType maps to Type which say Vec<u8>
37 let field_name = "buffer".to_string();
38 let entry = FieldEntry::new_bytes(field_name);
39 let _ = builder.add_field(entry);
40
41 let text_options = TextOptions::default();
42 let field_name = "labels".to_string();
43 let entry = FieldEntry::new_text(field_name, text_options);
44 let _ = builder.add_field(entry);
45
46 let schema = builder.build();
47 let document = schema.parse_document(&json_doc).expect("[Dies Coughing]");
48 println!("Document: {:#?}", document);
49}
Trait Implementations§
Source§impl Clone for SurferSchema
impl Clone for SurferSchema
Source§fn clone(&self) -> SurferSchema
fn clone(&self) -> SurferSchema
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for SurferSchema
impl Debug for SurferSchema
Source§impl Deref for SurferSchema
impl Deref for SurferSchema
Source§impl DerefMut for SurferSchema
impl DerefMut for SurferSchema
Source§impl Display for SurferSchema
impl Display for SurferSchema
Source§impl PartialEq for SurferSchema
impl PartialEq for SurferSchema
impl Eq for SurferSchema
impl StructuralPartialEq for SurferSchema
Auto Trait Implementations§
impl Freeze for SurferSchema
impl RefUnwindSafe for SurferSchema
impl Send for SurferSchema
impl Sync for SurferSchema
impl Unpin for SurferSchema
impl UnwindSafe for SurferSchema
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
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
.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
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)
Convert
&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)
Convert
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.