Skip to main content

search_with

Function search_with 

Source
pub fn search_with<C, F, R, S>(
    query: &[(DimId, Weight)],
    filter: F,
    cursors: R,
    sink: S,
    options: SearchOptions,
    scratch: &mut Scratch,
) -> Vec<(RecordId, f32)>
where C: PostingCursor, F: Fn(RecordId) -> bool, R: FnMut(DimId) -> Option<C>, S: ScoreSink,
Expand description

search with an explicit sink, options and scratch buffers.

Before any lane is built the query is normalised: duplicated dimensions are merged by summing their weights and zero weights are dropped, so [(3, 1.0), (3, 0.5)] scores exactly like [(3, 1.5)].

Per window, the loop scores every record present in a lane, then offers to the sink only the records whose score strictly exceeds the sink’s current threshold — the threshold only rises, so a record that cannot beat it now never could — and only those go through filter. Pruning (a sort of the lanes) is attempted once per distinct threshold value: a window that did not move the threshold does not pay for it.