FunctionChain
This struct describes a named sequence of operations applied to search results, attached to a search request through SearchRequestBuilder::function_chains.
pub struct FunctionChain
PARAMETERS:
name: StringName of the chain.
stage: FunctionChainStageExecution stage of the chain. Must not be
Unspecifiedwhen used for search.ops: Vec<FunctionChainOp>Ordered operations in the chain. Must contain at least one operation.
METHODS:
new()- Creates a value initialized with its SDK defaults.name(value)/set_name(value)/get_name()- Sets or returns the chain name.stage(value)/set_stage(value)/get_stage()- Sets or returns the execution stage.ops(value)/set_ops(value)/get_ops()- Sets or returns the ordered operations.add_op(op)- Appends a rawFunctionChainOp, for operations the fluent conveniences do not expose, such asfilterormerge.map(output, expr)- Appends amapoperation that writes an expression result to an output column.sort(by, desc, tie_break_col)- Appends asortoperation by a column, optionally with a tie-break column.limit(limit, offset)- Appends alimitoperation with an optional offset.validate()- Validates that the chain can be attached to a search request.
FunctionChainStage
Defines the lifecycle stage where a chain operation runs.
pub enum FunctionChainStage {
Unspecified,
Ingestion,
PreProcess,
L0Rerank,
L1Rerank,
L2Rerank,
PostProcess,
}
Constants:
Unspecified
Unset stage; the default. Not supported for search.
Ingestion
Stage applied during data ingestion.
PreProcess
Stage applied before search.
L0Rerank
First-level rerank stage.
L1Rerank
Second-level rerank stage.
L2Rerank
Third-level rerank stage.
PostProcess
Stage applied after search.
FunctionChainArg
Defines one argument passed to a map-stage expression.
pub enum FunctionChainArg {
Column(String),
Literal(FunctionParamValue),
}
Constants:
Column(String)
References an input column by name.
Literal(FunctionParamValue)
Carries a literal parameter value.
The helper function col(name) builds a FunctionChainArg::Column.
FunctionParamValue
Defines a typed parameter value accepted by a map-stage expression.
pub enum FunctionParamValue {
Bool(bool),
Int(i64),
Double(f64),
String(String),
Bytes(Vec<u8>),
Array(Vec<FunctionParamValue>),
Object(HashMap<String, FunctionParamValue>),
}
Constants:
Bool(bool)
A boolean parameter value.
Int(i64)
A 64-bit integer parameter value.
Double(f64)
A floating-point parameter value.
String(String)
A string parameter value.
Bytes(Vec
) A raw byte-string parameter value.
Array(Vec
) An array of parameter values, built with
FunctionParamValue::array(...).Object(HashMap
) A map of parameter values, built with
FunctionParamValue::object(...).
FunctionParamValue implements From conversions for bool, integer, float, string, byte-slice, array, and object types.
FunctionChainExpr
This struct describes a named expression with arguments and parameters used by a map operation.
pub struct FunctionChainExpr
PARAMETERS:
name: StringName of the expression, for example
num_combine.args: Vec<FunctionChainArg>Expression arguments, either column references or literals.
params: HashMap<String, FunctionParamValue>Expression parameters.
METHODS:
new()- Creates a value initialized with its SDK defaults.name(value)/set_name(value)- Sets the expression name.args(value)/set_args(value)/add_arg(value)- Sets, returns, or appends expression arguments.params(value)/set_params(value)/add_param(key, value)- Sets, returns, or adds expression parameters.get_name()/get_args()/get_params()- Returns the configured values.
FunctionChainOp
This struct describes one operation in a function chain.
pub struct FunctionChainOp
PARAMETERS:
op: StringOperation name, such as
map,sort, orlimit.expr: Option<FunctionChainExpr>Expression attached to the operation, required for
map.inputs: Vec<String>Input columns of the operation.
outputs: Vec<String>Output columns of the operation.
params: HashMap<String, FunctionParamValue>Operation parameters.
METHODS:
new()- Creates a value initialized with its SDK defaults.op(value)/set_op(value)/get_op()- Sets or returns the operation name.expr(value)/set_expr(value)/get_expr()- Sets or returns the expression.inputs(value)/set_inputs(value)/add_input(value)- Sets, returns, or appends input columns.outputs(value)/set_outputs(value)/add_output(value)- Sets, returns, or appends output columns.params(value)/set_params(value)/add_param(key, value)- Sets, returns, or adds operation parameters.
Example
let chain = FunctionChain::new()
.name("post_process")
.stage(FunctionChainStage::PostProcess)
.map("score_boosted", FunctionChainExpr::new().name("num_combine").add_arg(col("score")).add_param("weight", 1.5))
.limit(5, 0);