Skip to main content

TantivyDocument

Struct TantivyDocument 

Source
pub struct TantivyDocument {
    pub node_data: Vec<u8>,
    /* private fields */
}
Expand description

The default document in tantivy. It encodes data in a compact form.

Fields§

§node_data: Vec<u8>

node_data is a vec of bytes, where each value is serialized into bytes and stored. It includes all the data of the document and also metadata like where the nodes are located in an object or array.

Implementations§

Source§

impl CompactDoc

Source

pub fn with_capacity(bytes: usize) -> CompactDoc

Creates a new, empty document object The reserved capacity is for the total serialized data

Source

pub fn new() -> CompactDoc

Creates a new, empty document object

Source

pub fn shrink_to_fit(&mut self)

Skrinks the capacity of the document to fit the data

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: AsRef<str>>(&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(&mut self, field: Field, value: &[u8])

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<'a, V: Value<'a>>(&mut self, field: Field, value: V)

Add a (field, value) to the document.

OwnedValue implements Value, which should be easiest to use, but is not the most performant.

Source

pub fn add_leaf_field_value<'a, T: Into<ReferenceValueLeaf<'a>>>( &mut self, field: Field, typed_val: T, )

Add a (field, leaf value) to the document. Leaf values don’t have nested values.

Source

pub fn field_values(&self) -> impl Iterator<Item = (Field, CompactDocValue<'_>)>

field_values accessor

Source

pub fn get_all( &self, field: Field, ) -> impl Iterator<Item = CompactDocValue<'_>> + '_

Returns all of the ReferenceValues associated the given field

Source

pub fn get_first(&self, field: Field) -> Option<CompactDocValue<'_>>

Returns the first ReferenceValue associated the given field

Source

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

Create document from a named doc.

Source

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

Build a document object from a json-object.

Source

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

Build a document object from a json-object.

Trait Implementations§

Source§

impl Clone for CompactDoc

Source§

fn clone(&self) -> CompactDoc

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for CompactDoc

Source§

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

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

impl Default for CompactDoc

Source§

fn default() -> Self

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

impl Document for CompactDoc

Source§

type Value<'a> = CompactDocValue<'a>

The value of the field.
Source§

type FieldsValuesIter<'a> = FieldValueIterRef<'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 CompactDoc

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 Eq for CompactDoc

Source§

impl PartialEq for CompactDoc

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more

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>

Converts Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Converts Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Converts &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)

Converts &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> DowncastSend for T
where T: Any + Send,

Source§

fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>

Converts Box<Trait> (where Trait: DowncastSend) to Box<dyn Any + Send>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_sync(self: Box<T>) -> Box<dyn Any + Send + Sync>

Converts Box<Trait> (where Trait: DowncastSync) to Box<dyn Any + Send + Sync>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

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

Converts Arc<Trait> (where Trait: DowncastSync) to Arc<Any>, which can then be 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

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

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,

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.