K - Key type.V - Value type.public interface NodeSelectionVectorSetCommands<K,V>
Vector sets are a Redis data type designed for storing and searching high-dimensional vectors. They support approximate nearest neighbor search using the HNSW (Hierarchical Navigable Small World) algorithm.
Vector sets are particularly useful for machine learning applications, similarity search, recommendation systems, and other use cases that involve high-dimensional vector data.
| Modifier and Type | Method and Description |
|---|---|
Executions<Boolean> |
vadd(K key,
int dimensionality,
V element,
Double... vectors)
Add a new element into the vector set specified by
key with the specified dimensionality. |
Executions<Boolean> |
vadd(K key,
int dimensionality,
V element,
VAddArgs args,
Double... vectors)
Add a new element into the vector set specified by
key with the specified dimensionality and additional options. |
Executions<Boolean> |
vadd(K key,
V element,
Double... vectors)
Add a new element into the vector set specified by
key. |
Executions<Boolean> |
vadd(K key,
V element,
VAddArgs args,
Double... vectors)
Add a new element into the vector set specified by
key with additional options. |
Executions<Long> |
vcard(K key)
Returns the number of elements in the vector set stored at
key. |
Executions<Boolean> |
vClearAttributes(K key,
V element)
Clears all attributes for the specified
element in the vector set stored at key. |
Executions<Long> |
vdim(K key)
Returns the dimensionality of the vector set stored at
key. |
Executions<List<Double>> |
vemb(K key,
V element)
Returns the approximate vector associated with a given
element in the vector set stored at key. |
Executions<RawVector> |
vembRaw(K key,
V element)
Returns the raw vector data for the specified
element in the vector set stored at key. |
Executions<String> |
vgetattr(K key,
V element)
Returns the attributes associated with the specified
element in the vector set stored at key. |
Executions<List<JsonValue>> |
vgetattrAsJsonValue(K key,
V element)
Returns the attributes associated with the specified
element in the vector set stored at key. |
Executions<VectorMetadata> |
vinfo(K key)
Returns metadata and internal details about the vector set stored at
key. |
Executions<List<V>> |
vlinks(K key,
V element)
Returns the neighbors of the specified
element in the HNSW graph of the vector set stored at key. |
Executions<Map<V,Double>> |
vlinksWithScores(K key,
V element)
Returns the neighbors of the specified
element in the HNSW graph along with their scores. |
Executions<V> |
vrandmember(K key)
Returns a random element from the vector set stored at
key. |
Executions<List<V>> |
vrandmember(K key,
int count)
Returns multiple random elements from the vector set stored at
key. |
Executions<Boolean> |
vrem(K key,
V element)
Removes the specified
element from the vector set stored at key. |
Executions<Boolean> |
vsetattr(K key,
V element,
JsonValue json)
Sets or updates the attributes for the specified
element in the vector set stored at key. |
Executions<Boolean> |
vsetattr(K key,
V element,
String json)
Sets or updates the attributes for the specified
element in the vector set stored at key. |
Executions<List<V>> |
vsim(K key,
Double... vectors)
Finds the most similar vectors to the given query vector in the vector set stored at
key. |
Executions<List<V>> |
vsim(K key,
V element)
Finds the most similar vectors to the given element's vector in the vector set stored at
key. |
Executions<List<V>> |
vsim(K key,
VSimArgs args,
Double... vectors)
Finds the most similar vectors to the given query vector in the vector set stored at
key with additional options. |
Executions<List<V>> |
vsim(K key,
VSimArgs args,
V element)
Finds the most similar vectors to the given element's vector in the vector set stored at
key with additional
options. |
Executions<Map<V,Double>> |
vsimWithScore(K key,
Double... vectors)
Finds the most similar vectors to the given query vector in the vector set stored at
key and returns them with
their similarity scores. |
Executions<Map<V,Double>> |
vsimWithScore(K key,
V element)
Finds the most similar vectors to the given element's vector in the vector set stored at
key and returns them
with their similarity scores. |
Executions<Map<V,Double>> |
vsimWithScore(K key,
VSimArgs args,
Double... vectors)
Finds the most similar vectors to the given query vector in the vector set stored at
key with additional options
and returns them with their similarity scores. |
Executions<Map<V,Double>> |
vsimWithScore(K key,
VSimArgs args,
V element)
Finds the most similar vectors to the given element's vector in the vector set stored at
key with additional
options and returns them with their similarity scores. |
Executions<Map<V,VSimScoreAttribs>> |
vsimWithScoreWithAttribs(K key,
Double... vectors)
Finds the most similar vectors to the given query vector in the vector set stored at
key and returns them with
their similarity scores and attributes. |
Executions<Map<V,VSimScoreAttribs>> |
vsimWithScoreWithAttribs(K key,
V element)
Finds the most similar vectors to the given element's vector in the vector set stored at
key and returns them
with their similarity scores and attributes. |
Executions<Map<V,VSimScoreAttribs>> |
vsimWithScoreWithAttribs(K key,
VSimArgs args,
Double... vectors)
Finds the most similar vectors to the given query vector in the vector set stored at
key with additional options
and returns them with their similarity scores and attributes. |
Executions<Map<V,VSimScoreAttribs>> |
vsimWithScoreWithAttribs(K key,
VSimArgs args,
V element)
Finds the most similar vectors to the given element's vector in the vector set stored at
key with additional
options and returns them with their similarity scores and attributes. |
@Experimental Executions<Boolean> vadd(K key, V element, Double... vectors)
key.
By default, vectors are stored using int8 quantization for memory efficiency.
Time complexity: O(log(N)) for each element added, where N is the number of elements in the vector set.
key - the key of the vector setelement - the name of the element that is being added to the vector setvectors - the vector values as floating point numbers@Experimental Executions<Boolean> vadd(K key, int dimensionality, V element, Double... vectors)
key with the specified dimensionality.
This method allows implementing random projection to reduce the dimensionality of the vector. The projection matrix is saved and reloaded along with the vector set.
Time complexity: O(log(N)) for each element added, where N is the number of elements in the vector set.
key - the key of the vector setdimensionality - the reduced number of dimensions for the vectorelement - the name of the element that is being added to the vector setvectors - the vector values as floating point numbers@Experimental Executions<Boolean> vadd(K key, V element, VAddArgs args, Double... vectors)
key with additional options.
The VAddArgs allows configuring various options such as quantization type, exploration factor, and attributes.
Time complexity: O(log(N)) for each element added, where N is the number of elements in the vector set.
key - the key of the vector setelement - the name of the element that is being added to the vector setargs - the additional arguments for the VADD commandvectors - the vector values as floating point numbers@Experimental Executions<Boolean> vadd(K key, int dimensionality, V element, VAddArgs args, Double... vectors)
key with the specified dimensionality and additional options.
This method allows implementing random projection to reduce the dimensionality of the vector. The projection matrix is
saved and reloaded along with the vector set. Additional options could be specified via VAddArgs.
Time complexity: O(log(N)) for each element added, where N is the number of elements in the vector set.
key - the key of the vector setdimensionality - the reduced number of dimensions for the vectorelement - the name of the element that is being added to the vector setargs - the additional arguments for the VADD commandvectors - the vector values as floating point numbers@Experimental Executions<Long> vcard(K key)
key.
Time complexity: O(1)
key - the key of the vector set@Experimental Executions<Boolean> vClearAttributes(K key, V element)
element in the vector set stored at key.
Time complexity: O(1)
key - the key of the vector setelement - the name of the element in the vector set@Experimental Executions<Long> vdim(K key)
key.
Time complexity: O(1)
key - the key of the vector set@Experimental Executions<List<Double>> vemb(K key, V element)
element in the vector set stored at key.
Vector sets normalize and may quantize vectors on insertion. VEMB reverses this process to approximate the original
vector by de-normalizing and de-quantizing it. To retrieve the raw vector data, use #vembRaw(K, V).
Time complexity: O(N) where N is the dimensionality of the vector
key - the key of the vector setelement - the name of the element in the vector set@Experimental Executions<RawVector> vembRaw(K key, V element)
element in the vector set stored at key.
This method returns the vector in its raw binary format, which can be more efficient for large vectors.
Time complexity: O(N) where N is the dimensionality of the vector
key - the key of the vector setelement - the name of the element in the vector set@Experimental Executions<String> vgetattr(K key, V element)
element in the vector set stored at key.
Attributes are stored as JSON and can contain any metadata associated with the vector element.
Time complexity: O(1)
key - the key of the vector setelement - the name of the element in the vector set@Experimental Executions<List<JsonValue>> vgetattrAsJsonValue(K key, V element)
element in the vector set stored at key.
Attributes are stored as JSON and can contain any metadata associated with the vector element.
Time complexity: O(1)
key - the key of the vector setelement - the name of the element in the vector setJsonValue, or null if the key or element does not exist or has no
attributes@Experimental Executions<VectorMetadata> vinfo(K key)
key.
The information includes details such as the number of elements, dimensionality, quantization type, and memory usage.
Time complexity: O(1)
key - the key of the vector set@Experimental Executions<List<V>> vlinks(K key, V element)
element in the HNSW graph of the vector set stored at key.
Links represent connections to other elements in the graph structure used for similarity search.
Time complexity: O(M) where M is the maximum number of links per node
key - the key of the vector setelement - the name of the element in the vector set@Experimental Executions<Map<V,Double>> vlinksWithScores(K key, V element)
element in the HNSW graph along with their scores.
The scores represent the similarity between the specified element and its linked elements.
Time complexity: O(M) where M is the maximum number of links per node
key - the key of the vector setelement - the name of the element in the vector set@Experimental Executions<V> vrandmember(K key)
key. This command is useful for sampling elements for
testing or training or generating random queries for performance testing.
Time complexity: O(1)
key - the key of the vector set@Experimental Executions<List<V>> vrandmember(K key, int count)
key. This command is useful for sampling elements
for testing or training or generating random queries for performance testing.
key - the key of the vector setcount - the number of random elements to return@Experimental Executions<Boolean> vrem(K key, V element)
element from the vector set stored at key.
VREM reclaims memory immediately. It does not use tombstones or logical deletions, making it safe to use in long-running applications that frequently update the same vector set. Time complexity: O(log(N)) where N is the number of elements in the vector set
key - the key of the vector setelement - the name of the element to remove from the vector set@Experimental Executions<Boolean> vsetattr(K key, V element, String json)
element in the vector set stored at key.
Attributes are stored as JSON and can contain any metadata associated with the vector element. You can also update existing attributes or delete them by setting an empty string.
Time complexity: O(1)
key - the key of the vector setelement - the name of the element in the vector setjson - the attributes as a JSON string@Experimental Executions<Boolean> vsetattr(K key, V element, JsonValue json)
element in the vector set stored at key.
Attributes are stored as JSON and can contain any metadata associated with the vector element. You can also update existing attributes or delete them by setting an empty string.
Time complexity: O(1)
key - the key of the vector setelement - the name of the element in the vector setjson - the attributes as a JsonValue object@Experimental Executions<List<V>> vsim(K key, Double... vectors)
key.
This method performs a similarity search using the HNSW algorithm.
Time complexity: O(log(N)) where N is the number of elements in the vector set
key - the key of the vector setvectors - the query vector values as floating point numbers@Experimental Executions<List<V>> vsim(K key, V element)
key.
This method performs a similarity search using the vector of an existing element as the query.
Time complexity: O(log(N)) where N is the number of elements in the vector set
key - the key of the vector setelement - the name of the element whose vector will be used as the query@Experimental Executions<List<V>> vsim(K key, VSimArgs args, Double... vectors)
key with additional options.
The VSimArgs allows configuring various options such as the number of results, exploration factor, and filtering.
Time complexity: O(log(N)) where N is the number of elements in the vector set
key - the key of the vector setargs - the additional arguments for the VSIM commandvectors - the query vector values as floating point numbers@Experimental Executions<List<V>> vsim(K key, VSimArgs args, V element)
key with additional
options.
This method combines using an existing element's vector as the query with the ability to specify additional options via
VSimArgs.
Time complexity: O(log(N)) where N is the number of elements in the vector set
key - the key of the vector setelement - the name of the element whose vector will be used as the queryargs - the additional arguments for the VSIM command@Experimental Executions<Map<V,Double>> vsimWithScore(K key, Double... vectors)
key and returns them with
their similarity scores.
The similarity scores represent the distance between the query vector and the result vectors.
Time complexity: O(log(N)) where N is the number of elements in the vector set
key - the key of the vector setvectors - the query vector values as floating point numbers@Experimental Executions<Map<V,Double>> vsimWithScore(K key, V element)
key and returns them
with their similarity scores.
The similarity scores represent the distance between the specified element's vector and the result vectors.
Time complexity: O(log(N)) where N is the number of elements in the vector set
key - the key of the vector setelement - the name of the element whose vector will be used as the query@Experimental Executions<Map<V,Double>> vsimWithScore(K key, VSimArgs args, Double... vectors)
key with additional options
and returns them with their similarity scores.
The VSimArgs allows configuring various options such as the number of results, exploration factor, and filtering.
Time complexity: O(log(N)) where N is the number of elements in the vector set
key - the key of the vector setargs - the additional arguments for the VSIM commandvectors - the query vector values as floating point numbers@Experimental Executions<Map<V,Double>> vsimWithScore(K key, VSimArgs args, V element)
key with additional
options and returns them with their similarity scores.
This method combines using an existing element's vector as the query with the ability to specify additional options via
VSimArgs.
Time complexity: O(log(N)) where N is the number of elements in the vector set
key - the key of the vector setelement - the name of the element whose vector will be used as the queryargs - the additional arguments for the VSIM command@Experimental Executions<Map<V,VSimScoreAttribs>> vsimWithScoreWithAttribs(K key, Double... vectors)
key and returns them with
their similarity scores and attributes.
The similarity scores represent the distance between the query vector and the result vectors. Attributes are returned as a server-provided string.
Time complexity: O(log(N)) where N is the number of elements in the vector set
key - the key of the vector setvectors - the query vector values as floating point numbers@Experimental Executions<Map<V,VSimScoreAttribs>> vsimWithScoreWithAttribs(K key, V element)
key and returns them
with their similarity scores and attributes.
The similarity scores represent the distance between the specified element's vector and the result vectors. Attributes are returned as a server-provided string.
Time complexity: O(log(N)) where N is the number of elements in the vector set
key - the key of the vector setelement - the name of the element whose vector will be used as the query@Experimental Executions<Map<V,VSimScoreAttribs>> vsimWithScoreWithAttribs(K key, VSimArgs args, Double... vectors)
key with additional options
and returns them with their similarity scores and attributes.
The VSimArgs allows configuring various options such as the number of results (COUNT), epsilon cutoff
(EPSILON), exploration factor (EF), and filtering.
Time complexity: O(log(N)) where N is the number of elements in the vector set
key - the key of the vector setargs - the additional arguments for the VSIM commandvectors - the query vector values as floating point numbers@Experimental Executions<Map<V,VSimScoreAttribs>> vsimWithScoreWithAttribs(K key, VSimArgs args, V element)
key with additional
options and returns them with their similarity scores and attributes.
This method combines using an existing element's vector as the query with the ability to specify additional options via
VSimArgs. Attributes are returned as a server-provided string.
Time complexity: O(log(N)) where N is the number of elements in the vector set
key - the key of the vector setelement - the name of the element whose vector will be used as the queryargs - the additional arguments for the VSIM commandCopyright © 2025 lettuce.io. All rights reserved.