formula

fun formula(expression: Expression, defaults: Map<String, JsonPrimitive> = emptyMap())

Rescore the candidates with an arithmetic formula rather than by distance. Pair it with prefetch to narrow the candidates first: a formula over the whole collection is a full scan.

search("products") {
prefetch { query(queryVector); limit = 100 }
formula(Expression.sum(Expression.score, Expression.key("popularity")))
limit = 10
}

Parameters

defaults

values substituted for payload keys a candidate does not have; without an entry a missing key fails the query rather than counting as zero.