pub fn from_tantivy_document(
        ctx: &SchemaContext,
        doc_id: u64,
        mut doc: tantivy::schema::NamedFieldDocument,
        score: Option<Score>,
    ) -> Self {
        let mut compliant = HashMap::with_capacity(doc.0.len());
        for (name, info) in ctx.fields() {
            let val = match doc.0.remove(name) {
                Some(mut val) => {
                    if info.is_multi() {
                        Some(CompliantDocumentValue::Multi(val))
                    } else {
                        val.pop().map(CompliantDocumentValue::Single)
                    }
                },
                None => {
                    if info.is_multi() {
                        Some(CompliantDocumentValue::Multi(vec![]))
                    } else {
                        None
                    }
                },
            };

            compliant.insert(name.clone(), val);
        }

        Self {
            doc: compliant,
            document_id: doc_id,
            score,
        }
    }
/// Converts a tantivy document into a document matching
/// the given schema.
Converts a tantivy document into a document matching
the given schema.
Converts a tantivy document into a document matching the given schema .
pub fn from_tantivy_document(
        ctx: &SchemaContext,
        doc_id: u64,
        mut doc: tantivy::schema::NamedFieldDocument,
        score: Option<Score>,
    ) -> Self {
        let mut compliant = HashMap::with_capacity(doc.0.len());
        for (name, info) in ctx.fields() {
            let val = match doc.0.remove(name) {
                Some(mut val) => {
                    if info.is_multi() {
                        Some(CompliantDocumentValue::Multi(val))
                    } else {
                        val.pop().map(CompliantDocumentValue::Single)
                    }
                },
                None => {
                    if info.is_multi() {
                        Some(CompliantDocumentValue::Multi(vec![]))
                    } else {
                        None
                    }
                },
            };
            compliant.insert(name.clone(), val);
        }
        Self {
            doc: compliant,
            document_id: doc_id,
            score,
        }
    }
pub fn from_tantivy_document ( ctx : & SchemaContext , doc_id : u64 , mut doc : tantivy :: schema :: NamedFieldDocument , score : Option < Score > , ) -> Self { let mut compliant = HashMap :: with_capacity ( doc . 0 . len ( ) ) ; for ( name , info ) in ctx . fields ( ) { let val = match doc . 0 . remove ( name ) { Some ( mut val ) => { if info . is_multi ( ) { Some ( CompliantDocumentValue :: Multi ( val ) ) } else { val . pop ( ) . map ( CompliantDocumentValue :: Single ) } } , None => { if info . is_multi ( ) { Some ( CompliantDocumentValue :: Multi ( vec ! [ ] ) ) } else { None } } , } ; compliant . insert ( name . clone ( ) , val ) ; } Self { doc : compliant , document_id : doc_id , score , } }
Converts a tantivy document into a document matching
the given schema.
Converts a tantivy document into a document matching the given schema .
ctx
&SchemaContext
doc_id
u64
doc
tantivy::schema::NamedFieldDocument
score
Option<Score>
ctx
&SchemaContext
doc_id
u64
doc
tantivy::schema::NamedFieldDocument
score
Option<Score>