Expression
An arithmetic expression over a point's score and payload, evaluated by Qdrant to rerank the candidates a Prefetch produced.
This is the "boost by business rules" layer: multiply the vector score by a popularity field, add a bonus for points matching a condition, decay by recency or by distance. It runs on the server, over candidates that have already been narrowed, which is what makes it cheap enough to be worth doing.
// relevance, boosted for in-stock items and decayed by how far away the seller is
qdrant.search("products") {
prefetch { query(queryVector); limit = 100 }
formula(
Expression.sum(
Expression.score,
Expression.mult(Expression.of(0.5), Expression.condition(filter { must { "in_stock" eq true } })),
Expression.expDecay(Expression.geoDistance(origin = here, to = "seller_location"), scale = 5_000.0),
),
)
limit = 10
}Request-only: Qdrant never returns an expression, so this serializes but does not deserialize.
Inheritors
Types
Absolute value.
A filter condition as a number: 1.0 when the point matches, 0.0 when it does not.
An RFC 3339 datetime as a Unix timestamp.
A payload key holding a datetime, as a Unix timestamp.
left divided by right. byZeroDefault is what the division evaluates to when right is zero; without it Qdrant fails the query rather than inventing a number.
Natural exponential.
Exponential decay of params.
Gaussian decay of params.
Linear decay of params.
Natural logarithm.
Base-10 logarithm.
The product of every operand.
Arithmetic negation.
Square root.
The sum of every operand.
A constant.
A payload key, or one of Qdrant's variables. $score is the vector score of the candidate; a plain key reads that payload field, and a missing field evaluates to the formula's default for that key (see defaults) or fails the query.