Skip to main content

index_admissible_for_skip_if_absent

Function index_admissible_for_skip_if_absent 

Source
pub fn index_admissible_for_skip_if_absent(
    index: &Index,
    fields: &[&str],
) -> bool
Expand description

Whether a query binding fields (its equal/in/range and order-by fields, as assembled for the index matcher) may be served by index given its skipIfAbsent participation.

A skipIfAbsent index holds only the documents that carry its trigger (the first property) — it is a SPARSE projection of the document type. The generic matcher does not require contiguously bound prefixes: an unused property, the leading trigger included, merely counts toward the difference score, so without this gate a query that never mentions the trigger could route here and silently omit every trigger-absent document — a result a complete index would have included (and the positional path lowering would additionally mis-assemble the prefix gap). Requiring the trigger among the query’s fields makes the sparse semantics opt-in: whoever binds the trigger is asking “among documents carrying this property”, which is exactly what the index holds. The count pickers and the multiple-In route need no such gate — their exact-cover / contiguous-prefix matching already binds position 0.