Zvec.Query (zvec v0.4.0)

Copy Markdown View Source

Query builder for zvec vector searches.

Example

query = Zvec.Query.vector("embedding", [0.1, 0.2, 0.3, 0.4], topk: 10)
query = Zvec.Query.vector("embedding", vec_binary, topk: 10, filter: "category = 'ai'")

Summary

Functions

Convert a raw float-32-native binary back to a list of floats.

Convert a list of floats to a raw float-32-native binary.

Functions

binary_to_float_list(bin)

@spec binary_to_float_list(binary()) :: [float()]

Convert a raw float-32-native binary back to a list of floats.

float_list_to_binary(list)

@spec float_list_to_binary([float()]) :: binary()

Convert a list of floats to a raw float-32-native binary.

vector(field_name, vector, opts \\ [])

@spec vector(String.t(), [float()] | binary(), keyword()) :: map()

Build a vector query.

The vector argument can be:

  • A list of floats (will be converted to a raw float32 binary)
  • A raw binary (used as-is)

Options

  • :topk - number of results to return (default: 10)
  • :filter - SQL-like filter expression
  • :include_vector - whether to include vectors in results (default: false)
  • :output_fields - list of field names to include in results
  • :query_params - search params map, e.g. %{type: :hnsw, ef: 200} Supported types: :hnsw, :flat, :ivf, :hnsw_rabitq, :vamana :hnsw / :hnsw_rabitq keys: :ef, :radius, :is_linear, :is_using_refiner :vamana keys: :ef_search, :radius, :is_linear, :is_using_refiner :ivf keys: :nprobe, :scale_factor, :is_using_refiner :flat keys: :scale_factor, :is_using_refiner