Milvex.Function
(milvex v0.10.2)
Copy Markdown
Builder for Milvus function schemas.
Functions define transformations on fields, such as BM25 full-text search that converts text to sparse embeddings.
Examples
# BM25 function for full-text search
function = Function.bm25("bm25_fn", input: "content", output: "sparse")
# Using with fluent builder
function = Function.new("bm25_fn", :BM25)
|> Function.input_field_names(["content"])
|> Function.output_field_names(["sparse"])
Summary
Functions
Creates a BM25 function for full-text search.
Creates a Function from a protobuf FunctionSchema struct.
Sets the input field names for the function.
Creates a new function with the given name and type.
Sets the output field names for the function.
Adds a parameter to the function.
Converts the function to a protobuf FunctionSchema struct.
Types
Functions
Creates a BM25 function for full-text search.
BM25 converts text fields to sparse vector embeddings for full-text search.
Note: Milvus BM25 functions only support a single input field and a single output field. If you need to search multiple text fields, create separate BM25 functions for each field with their own sparse vector output fields, then use hybrid search to combine the results.
Options
:input- Input field name (required, single VARCHAR field):output- Output field name (required, single SPARSE_FLOAT_VECTOR field)
Examples
Function.bm25("bm25_fn", input: "content", output: "sparse")
# For multiple text fields, create separate functions:
Function.bm25("title_bm25", input: "title", output: "title_sparse")
Function.bm25("content_bm25", input: "content", output: "content_sparse")
@spec from_proto(Milvex.Milvus.Proto.Schema.FunctionSchema.t()) :: t()
Creates a Function from a protobuf FunctionSchema struct.
Sets the input field names for the function.
@spec new(String.t(), function_type()) :: t()
Creates a new function with the given name and type.
Parameters
name- Function nametype- Function type (:BM25, :TextEmbedding, :Rerank)
Examples
Function.new("bm25_fn", :BM25)
Sets the output field names for the function.
Adds a parameter to the function.
@spec to_proto(t()) :: Milvex.Milvus.Proto.Schema.FunctionSchema.t()
Converts the function to a protobuf FunctionSchema struct.