Builder for zvec collection schemas.
Example
schema =
Zvec.Schema.new("my_collection")
|> Zvec.Schema.add_field("text", :string, index: %{type: :invert})
|> Zvec.Schema.add_vector("embedding", 384, index: %{type: :hnsw, metric_type: :cosine})
Summary
Functions
Add a scalar field to the schema.
Add a dense vector field to the schema.
Set the maximum document count per segment.
Create a new schema with the given collection name.
Convert the schema struct to the NIF-compatible map format.
Types
@type t() :: %Zvec.Schema{ fields: [map()], max_doc_count_per_segment: pos_integer() | nil, name: String.t() }
Functions
Add a scalar field to the schema.
Options
:nullable- whether the field can be null (default:false):index- index params map, e.g.%{type: :invert}
@spec add_vector(t(), String.t(), pos_integer(), keyword()) :: t()
Add a dense vector field to the schema.
Options
:type- vector element type (default::vector_fp32):nullable- whether the field can be null (default:false):index- index params map, e.g.%{type: :hnsw, metric_type: :cosine}Supported types::hnsw,:flat,:ivf,:invert,:hnsw_rabitq,:vamana:hnswoptions::m(default 16),:ef_construction(default 200),:use_contiguous_memory(default false):hnsw_rabitqoptions::total_bits(default 7),:num_clusters(default 16),:m,:ef_construction:vamanaoptions::max_degree(default 64),:search_list_size(default 100),:alpha(default 1.2),:saturate_graph(default false),:use_contiguous_memory(default false),:use_id_map(default false) Quantization is specified in the:indexparams map withquantize_type: :fp16 | :int8 | :int4 | :rabitqSupported for vector index types:hnsw,:flat,:ivf, and:vamana
@spec max_doc_count_per_segment(t(), pos_integer()) :: t()
Set the maximum document count per segment.
Create a new schema with the given collection name.
Convert the schema struct to the NIF-compatible map format.