Command builders for Redis Vector Set operations (Redis 8.0+).
Vector Sets are a data type for approximate nearest-neighbor similarity search. Each element is associated with a high-dimensional vector, and the set supports efficient queries for the most similar elements.
Every function returns a plain list of strings (a command). To execute
a command, pass the result to Redis.command/2; to batch several
commands in a single round trip, use Redis.pipeline/2.
Examples
Adding elements with vectors:
iex> Redis.command(conn, Redis.Commands.VectorSet.vadd("vs", "item1", [1.0, 2.0, 3.0]))
{:ok, 1}Searching for similar elements:
iex> Redis.command(conn, Redis.Commands.VectorSet.vsim("vs", {:vector, [1.0, 2.0, 3.0]}, count: 5))
{:ok, ["item1", "item2"]}Getting element embeddings:
iex> Redis.command(conn, Redis.Commands.VectorSet.vemb("vs", "item1"))
{:ok, [1.0, 2.0, 3.0]}
Summary
Functions
Builds a VADD command to add an element with a vector to the vector set at key.
Builds a VCARD command to return the number of elements in the vector set at key.
Builds a VDIM command to return the vector dimensions of the vector set at key.
Builds a VEMB command to get the embedding vector of an element.
Builds a VGETATTR command to get the JSON attributes of an element.
Builds a VINFO command to return information about the vector set at key.
Builds a VLINKS command to get the graph links of an element.
Builds a VRANDMEMBER command to return one or more random elements.
Builds a VREM command to remove an element from the vector set at key.
Builds a VSETATTR command to set JSON attributes on an element.
Builds a VSIM command for similarity search.
Functions
Builds a VADD command to add an element with a vector to the vector set at key.
The vector is provided as a list of floats and serialized using the
VALUES count v1 v2 ... format.
Options
:reduce- reduce dimensionality to the given integer:quantization- quantization type::q8,:bin, or:noquant:ef- exploration factor for insertion:setattr- JSON string of attributes to associate with the element:cas- compare-and-swap value for conditional updates
Builds a VCARD command to return the number of elements in the vector set at key.
Builds a VDIM command to return the vector dimensions of the vector set at key.
Builds a VEMB command to get the embedding vector of an element.
Options
:raw- return raw binary representation
Builds a VGETATTR command to get the JSON attributes of an element.
Builds a VINFO command to return information about the vector set at key.
Builds a VLINKS command to get the graph links of an element.
Options
:withscores- include link scores in the reply
Builds a VRANDMEMBER command to return one or more random elements.
Options
:count- number of random elements to return
Builds a VREM command to remove an element from the vector set at key.
Builds a VSETATTR command to set JSON attributes on an element.
Builds a VSIM command for similarity search.
The search_input is either {:element, name} to search by an existing
element, or {:vector, [floats]} to search by a raw vector.
Options
:count- maximum number of results:ef- exploration factor for search:filter- FILTER expression string for attribute-based filtering:filter_ef- exploration factor for filtered search:truth- use brute-force exact search (boolean):nothread- disable multi-threading (boolean):withscores- include similarity scores in the reply (boolean)