SurferSchema

Struct SurferSchema 

Source
pub struct SurferSchema { /* private fields */ }

Implementations§

Source§

impl SurferSchema

Source

pub fn new( schema: Schema, mappings: HashMap<String, SurferFieldTypes>, track_tf: bool, track_tf_idf: bool, ) -> Self

Source

pub fn resolve_mapping(&self) -> &HashMap<String, SurferFieldTypes>

Methods from Deref<Target = Schema>§

Source

pub fn get_field_entry(&self, field: Field) -> &FieldEntry

Return the FieldEntry associated to a Field.

Source

pub fn get_field_name(&self, field: Field) -> &str

Return the field name for a given Field.

Source

pub fn fields(&self) -> impl Iterator<Item = (Field, &FieldEntry)>

Return the list of all the Fields.

Source

pub fn get_field(&self, field_name: &str) -> Option<Field>

Returns the field option associated with a given name.

Source

pub fn convert_named_doc( &self, named_doc: NamedFieldDocument, ) -> Result<Document, DocParsingError>

Create a named document off the doc.

Source

pub fn to_named_doc(&self, doc: &Document) -> NamedFieldDocument

Create a named document off the doc.

Source

pub fn to_json(&self, doc: &Document) -> String

Encode the schema in JSON.

Encoding a document cannot fail.

Source

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

Source§

fn clone(&self) -> SurferSchema

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SurferSchema

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Deref for SurferSchema

Source§

type Target = Schema

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl DerefMut for SurferSchema

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
Source§

impl Display for SurferSchema

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for SurferSchema

Source§

fn eq(&self, other: &SurferSchema) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for SurferSchema

Source§

impl StructuralPartialEq for SurferSchema

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Downcast for T
where T: Any,

Source§

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>

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)

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)

Convert &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> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> Erased for T

Source§

impl<T> Fruit for T
where T: Send + Downcast,