/// Extracts and validates the document id of a document.
Extracts and validates the document id of a document.
Extracts and validates the document id of a document .
pub fn extract_document_id(
    primary_key: &str,
    document: &IndexMap<String, Value>,
    external_docids: &FstMapCow,
    available_docids: &mut DiscoverIds<'_>,
) -> Result<(DocumentId, String), SerializerError>
{
    match document.get(primary_key) {
        Some(value) => {
            let docid = match value {
                Value::Number(number) => number.to_string(),
                Value::String(string) => string.clone(),
                _ => return Err(SerializerError::InvalidDocumentIdFormat),
            };
            discover_document_id(&docid, external_docids, available_docids).map(|id| (id, docid))
        }
        None => Err(SerializerError::DocumentIdNotFound),
    }
}
pub fn extract_document_id ( primary_key : & str , document : & IndexMap < String , Value > , external_docids : & FstMapCow , available_docids : & mut DiscoverIds < ' _ > , ) -> Result < ( DocumentId , String ) , SerializerError > { match document . get ( primary_key ) { Some ( value ) => { let docid = match value { Value :: Number ( number ) => number . to_string ( ) , Value :: String ( string ) => string . clone ( ) , _ => return Err ( SerializerError :: InvalidDocumentIdFormat ) , } ; discover_document_id ( & docid , external_docids , available_docids ) . map ( | id | ( id , docid ) ) } None => Err ( SerializerError :: DocumentIdNotFound ) , } }
Extracts and validates the document id of a document.
Extracts and validates the document id of a document .
primary_key
&str
document
&IndexMap<String, Value>
external_docids
&FstMapCow
available_docids
&mut DiscoverIds<'_>