function score
This block is part of the query group and was last modified in core v14.0.4.
Connection Type
This block connects from a query type block. Make sure to connect this block to the appropriate left-hand side connection.
function score v14.0.4 Wraps a query with function_score for custom relevance scoring. Builds script_score, random_score and decay functions from pins. The script_score scores documents by matching their tags field against the provided params : documents without a tags field return a neutral score of 1.
- Query required
queryThe inner query to apply scoring functions to.
- script params
objectParameters passed to the script_score function (e.g. { interests: { technology: 12 } }).
- script weight
numberWeight for the script_score function.
- random weight
numberWeight for random_score function for discovery sprinkle.
- decay type
valueDecay function type: exp, gauss, or linear.
- decay field
valueField to apply decay to.
- decay origin
valueOrigin point for the decay function.
- decay scale
valueScale for the decay function (e.g. 7d, 30d).
- decay value
numberDecay factor (0 to 1).
- decay weight
numberWeight for the decay function.
- score mode
valueHow function scores are combined: multiply, sum, avg, first, max, min.
- boost mode
valueHow function score combines with query score: multiply, replace, sum, avg, max, min.
- max boost
numberCaps the maximum effect of scoring functions.
- query
query
Wraps the inner query pin in a function_score clause that rewrites relevance scores without changing which documents match. A script_score is added only when script_params is a non-empty object (each document's tags field is scored against the given per-tag weights, documents without tags score a neutral 1; weight from script_weight, default 1); a random_score (weight default 0.15, seeded by the current time) and a decay function (default exp on _meta.created, origin "now", scale "7d", decay 0.5, weight 0.3) are ALWAYS added. Function scores combine per score_mode (default "sum") and replace the query score per boost_mode (default "replace"); max_boost is sent only when its pin is non-nil. An unwired inner query becomes {}, which matches everything.
A typical wiring for function score: fields feeds the query pin; the query out pin feeds cast to object.
Version history
Introduced in v14.0.4.
Back to
query Return to the main group to view all sub-groups Back to query Return to the group to view all blocks within this group 