Struct tantivy::schema::document::TantivyDocument

source ·
pub struct TantivyDocument { /* private fields */ }
Expand description

TantivyDocument provides a default implementation of the Document trait. It is the object that can be indexed and then searched for.

Documents are fundamentally a collection of unordered couples (field, value). In this list, one field may appear more than once.

Implementations§

source§

impl TantivyDocument

source

pub fn new() -> TantivyDocument

Creates a new, empty document object

source

pub fn len(&self) -> usize

Returns the length of the document.

source

pub fn add_facet<F>(&mut self, field: Field, path: F)
where Facet: From<F>,

Adding a facet to the document.

source

pub fn add_text<S: ToString>(&mut self, field: Field, text: S)

Add a text field.

source

pub fn add_pre_tokenized_text( &mut self, field: Field, pre_tokenized_text: PreTokenizedString )

Add a pre-tokenized text field.

source

pub fn add_u64(&mut self, field: Field, value: u64)

Add a u64 field

source

pub fn add_ip_addr(&mut self, field: Field, value: Ipv6Addr)

Add a IP address field. Internally only Ipv6Addr is used.

source

pub fn add_i64(&mut self, field: Field, value: i64)

Add a i64 field

source

pub fn add_f64(&mut self, field: Field, value: f64)

Add a f64 field

source

pub fn add_bool(&mut self, field: Field, value: bool)

Add a bool field

source

pub fn add_date(&mut self, field: Field, value: DateTime)

Add a date field with unspecified time zone offset

source

pub fn add_bytes<T: Into<Vec<u8>>>(&mut self, field: Field, value: T)

Add a bytes field

source

pub fn add_object(&mut self, field: Field, object: BTreeMap<String, OwnedValue>)

Add a dynamic object field

source

pub fn add_field_value<T: Into<OwnedValue>>( &mut self, field: Field, typed_val: T )

Add a (field, value) to the document.

source

pub fn field_values(&self) -> &[FieldValue]

field_values accessor

source

pub fn get_all(&self, field: Field) -> impl Iterator<Item = &OwnedValue>

Returns all of the FieldValues associated the given field

source

pub fn get_first(&self, field: Field) -> Option<&OwnedValue>

Returns the first FieldValue associated the given field

source

pub fn convert_named_doc( schema: &Schema, named_doc: NamedFieldDocument ) -> Result<TantivyDocument, DocParsingError>

Create document from a named doc.

source

pub fn parse_json( schema: &Schema, doc_json: &str ) -> Result<TantivyDocument, DocParsingError>

Build a document object from a json-object.

source

pub fn from_json_object( schema: &Schema, json_obj: Map<String, Value> ) -> Result<TantivyDocument, DocParsingError>

Build a document object from a json-object.

Trait Implementations§

source§

impl Clone for TantivyDocument

source§

fn clone(&self) -> TantivyDocument

Returns a copy 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 TantivyDocument

source§

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

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

impl Default for TantivyDocument

source§

fn default() -> TantivyDocument

Returns the “default value” for a type. Read more
source§

impl<'de> Deserialize<'de> for TantivyDocument

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl Document for TantivyDocument

§

type Value<'a> = &'a OwnedValue

The value of the field.
§

type FieldsValuesIter<'a> = FieldValueIter<'a>

The iterator over all of the fields and values within the doc.
source§

fn iter_fields_and_values(&self) -> Self::FieldsValuesIter<'_>

Get an iterator iterating over all fields and values in a document.
source§

fn get_sorted_field_values(&self) -> Vec<(Field, Vec<Self::Value<'_>>)>

Sort and groups the field_values by field. Read more
source§

fn to_named_doc(&self, schema: &Schema) -> NamedFieldDocument

Create a named document from the doc.
source§

fn to_json(&self, schema: &Schema) -> String

Encode the doc in JSON. Read more
source§

impl DocumentDeserialize for TantivyDocument

source§

fn deserialize<'de, D>(deserializer: D) -> Result<Self, DeserializeError>
where D: DocumentDeserializer<'de>,

Attempts to deserialize Self from a given document deserializer.
source§

impl From<Vec<FieldValue>> for TantivyDocument

source§

fn from(field_values: Vec<FieldValue>) -> Self

Converts to this type from the input type.
source§

impl IntoIterator for TantivyDocument

§

type Item = FieldValue

The type of the elements being iterated over.
§

type IntoIter = IntoIter<FieldValue>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

impl PartialEq for TantivyDocument

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Serialize for TantivyDocument

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl Eq for TantivyDocument

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> 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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
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<T> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

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

§

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, U> TryFrom<U> for T
where U: Into<T>,

§

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>,

§

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<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

source§

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