Skip to main content

search

Function search 

Source
pub fn search<C, F, R>(
    query: &[(DimId, Weight)],
    top_k: usize,
    filter: F,
    cursors: R,
) -> Vec<(RecordId, f32)>
where C: PostingCursor, F: Fn(RecordId) -> bool, R: FnMut(DimId) -> Option<C>,
Expand description

Top-k search by dot product.

query is a list of (dimension, weight); cursors resolves a dimension to a cursor over its posting list (None when the dimension is unknown or empty). Records rejected by filter are never returned. The result holds at most top_k (id, score) pairs, score descending then id ascending, where the score is the exact f32 sum over query dimensions of query_weight * record_weight, accumulated in dimension order.

A dimension listed several times in the query counts once, with the sum of its weights (see search_with).