Trait tantivy::schema::document::Document

source ·
pub trait Document: Send + Sync + 'static {
    type Value<'a>: Value<'a> + Clone
       where Self: 'a;
    type FieldsValuesIter<'a>: Iterator<Item = (Field, Self::Value<'a>)>
       where Self: 'a;

    // Required method
    fn iter_fields_and_values(&self) -> Self::FieldsValuesIter<'_>;

    // Provided methods
    fn get_sorted_field_values(&self) -> Vec<(Field, Vec<Self::Value<'_>>)> { ... }
    fn to_named_doc(&self, schema: &Schema) -> NamedFieldDocument { ... }
    fn to_json(&self, schema: &Schema) -> String { ... }
}
Expand description

The core trait representing a document within the index.

Required Associated Types§

source

type Value<'a>: Value<'a> + Clone where Self: 'a

The value of the field.

source

type FieldsValuesIter<'a>: Iterator<Item = (Field, Self::Value<'a>)> where Self: 'a

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

Required Methods§

source

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

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

Provided Methods§

source

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

Sort and groups the field_values by field.

The result of this method is not cached and is computed on the fly when this method is called.

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.

Encoding a document cannot fail.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl Document for BTreeMap<Field, OwnedValue>

§

type Value<'a> = &'a OwnedValue

§

type FieldsValuesIter<'a> = FieldCopyingIterator<'a, Iter<'a, Field, OwnedValue>, OwnedValue>

source§

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

source§

impl Document for HashMap<Field, OwnedValue>

§

type Value<'a> = &'a OwnedValue

§

type FieldsValuesIter<'a> = FieldCopyingIterator<'a, Iter<'a, Field, OwnedValue>, OwnedValue>

source§

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

Implementors§

source§

impl Document for TantivyDocument

§

type Value<'a> = &'a OwnedValue

§

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