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
impl TantivyDocument
sourcepub fn new() -> TantivyDocument
pub fn new() -> TantivyDocument
Creates a new, empty document object
sourcepub fn add_pre_tokenized_text(
&mut self,
field: Field,
pre_tokenized_text: PreTokenizedString
)
pub fn add_pre_tokenized_text( &mut self, field: Field, pre_tokenized_text: PreTokenizedString )
Add a pre-tokenized text field.
sourcepub fn add_ip_addr(&mut self, field: Field, value: Ipv6Addr)
pub fn add_ip_addr(&mut self, field: Field, value: Ipv6Addr)
Add a IP address field. Internally only Ipv6Addr is used.
sourcepub fn add_date(&mut self, field: Field, value: DateTime)
pub fn add_date(&mut self, field: Field, value: DateTime)
Add a date field with unspecified time zone offset
sourcepub fn add_object(&mut self, field: Field, object: BTreeMap<String, OwnedValue>)
pub fn add_object(&mut self, field: Field, object: BTreeMap<String, OwnedValue>)
Add a dynamic object field
sourcepub fn add_field_value<T: Into<OwnedValue>>(
&mut self,
field: Field,
typed_val: T
)
pub fn add_field_value<T: Into<OwnedValue>>( &mut self, field: Field, typed_val: T )
Add a (field, value) to the document.
sourcepub fn field_values(&self) -> &[FieldValue]
pub fn field_values(&self) -> &[FieldValue]
field_values accessor
sourcepub fn get_all(&self, field: Field) -> impl Iterator<Item = &OwnedValue>
pub fn get_all(&self, field: Field) -> impl Iterator<Item = &OwnedValue>
Returns all of the FieldValue
s associated the given field
sourcepub fn get_first(&self, field: Field) -> Option<&OwnedValue>
pub fn get_first(&self, field: Field) -> Option<&OwnedValue>
Returns the first FieldValue
associated the given field
sourcepub fn convert_named_doc(
schema: &Schema,
named_doc: NamedFieldDocument
) -> Result<TantivyDocument, DocParsingError>
pub fn convert_named_doc( schema: &Schema, named_doc: NamedFieldDocument ) -> Result<TantivyDocument, DocParsingError>
Create document from a named doc.
sourcepub fn parse_json(
schema: &Schema,
doc_json: &str
) -> Result<TantivyDocument, DocParsingError>
pub fn parse_json( schema: &Schema, doc_json: &str ) -> Result<TantivyDocument, DocParsingError>
Build a document object from a json-object.
sourcepub fn from_json_object(
schema: &Schema,
json_obj: Map<String, Value>
) -> Result<TantivyDocument, DocParsingError>
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
impl Clone for TantivyDocument
source§fn clone(&self) -> TantivyDocument
fn clone(&self) -> TantivyDocument
Returns a copy 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 TantivyDocument
impl Debug for TantivyDocument
source§impl Default for TantivyDocument
impl Default for TantivyDocument
source§fn default() -> TantivyDocument
fn default() -> TantivyDocument
Returns the “default value” for a type. Read more
source§impl<'de> Deserialize<'de> for TantivyDocument
impl<'de> Deserialize<'de> for TantivyDocument
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
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
impl Document for TantivyDocument
§type Value<'a> = &'a OwnedValue
type Value<'a> = &'a OwnedValue
The value of the field.
§type FieldsValuesIter<'a> = FieldValueIter<'a>
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<'_>
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<'_>>)>
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
fn to_named_doc(&self, schema: &Schema) -> NamedFieldDocument
Create a named document from the doc.
source§impl DocumentDeserialize for TantivyDocument
impl DocumentDeserialize for TantivyDocument
source§fn deserialize<'de, D>(deserializer: D) -> Result<Self, DeserializeError>where
D: DocumentDeserializer<'de>,
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
impl From<Vec<FieldValue>> for TantivyDocument
source§fn from(field_values: Vec<FieldValue>) -> Self
fn from(field_values: Vec<FieldValue>) -> Self
Converts to this type from the input type.
source§impl IntoIterator for TantivyDocument
impl IntoIterator for TantivyDocument
source§impl PartialEq for TantivyDocument
impl PartialEq for TantivyDocument
source§impl Serialize for TantivyDocument
impl Serialize for TantivyDocument
impl Eq for TantivyDocument
Auto Trait Implementations§
impl Freeze for TantivyDocument
impl RefUnwindSafe for TantivyDocument
impl Send for TantivyDocument
impl Sync for TantivyDocument
impl Unpin for TantivyDocument
impl UnwindSafe for TantivyDocument
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> 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.