Tantivy read data from fast field

Tantivy read data from fast field

Read data from fast field

additional documentation segment_reader.rs (fast_fields_readers)

let object_id_field = schema_builder.add_bytes_field("objectId", INDEXED | FAST);
    let lat = schema_builder.add_f64_field("lat", INDEXED | FAST);

    let query_results = searcher.search(
        &custom_query,
        &TopDocs::with_limit(10)
            .and_offset(0)
            .order_by_u64_field(lat),
    )?;

    for (_score, doc_address) in query_results {
        println!("{:?}", doc_address);
       
        let out = searcher
            .segment_reader(doc_address.segment_ord)
            .fast_fields()
            .bytes(object_id_field)
            .unwrap();
        println!(
            "{:?}",
            std::str::from_utf8(out.get_bytes(doc_address.doc_id)).unwrap()
        );
        let retrieved_doc = searcher.doc(doc_address)?;
        println!("{}", schema.to_json(&retrieved_doc));
    }

Related Posts