public class VAddArgs extends Object implements CompositeArgument
This class provides options for configuring how vectors are stored and indexed, including quantization type, exploration factor, attributes, and graph connectivity parameters.
Example usage:
VAddArgs args = VAddArgs.checkAndSet(true)
.quantizationType(QuantizationType.Q8)
.explorationFactor(200)
.attributes("{\"name\": \"Point A\", \"description\": \"First point added\"}"));
VAddArgs is a mutable object and instances should be used only once to avoid shared mutable state.
| Modifier and Type | Class and Description |
|---|---|
static class |
VAddArgs.Builder
Builder entry points for
VAddArgs. |
| Constructor and Description |
|---|
VAddArgs() |
| Modifier and Type | Method and Description |
|---|---|
VAddArgs |
attributes(JsonValue attributes)
Set the attributes for the vector (SETATTR).
|
VAddArgs |
attributes(String attributes)
Set the attributes for the vector (SETATTR).
|
<K,V> void |
build(CommandArgs<K,V> args)
Builds the command arguments based on the options set in this
VAddArgs instance. |
VAddArgs |
checkAndSet(boolean checkAndSet)
Set the CAS (Check-And-Set) flag for the vector addition.
|
VAddArgs |
explorationFactor(Long explorationFactor)
Set the exploration factor (EF) for the vector search.
|
VAddArgs |
maxNodes(Long maxNodes)
Set the maximum number of connections per node (M).
|
VAddArgs |
quantizationType(QuantizationType quantType)
Set the quantization type for the vector.
|
public VAddArgs checkAndSet(boolean checkAndSet)
The CAS option performs the operation partially using threads, in a check-and-set style. The neighbor candidates collection, which is slow, is performed in the background, while the command is executed in the main thread.
This can improve performance when adding vectors to large sets.
checkAndSet - whether to enable the check-and-set operation mode.thispublic VAddArgs quantizationType(QuantizationType quantType)
Quantization affects how vectors are stored and impacts memory usage, performance, and recall quality:
Q8 (default) - Uses signed 8-bit quantization, balancing memory usage and recall qualityNOQUANT - Stores vectors without quantization, using more memory but preserving full precisionBIN - Uses binary quantization, which is faster and uses less memory, but impacts recall qualityNote that these options are mutually exclusive.
quantType - the quantization type for the vector.thispublic VAddArgs explorationFactor(Long explorationFactor)
The EF option plays a role in the effort made to find good candidates when connecting the new node to the existing Hierarchical Navigable Small World (HNSW) graph.
The default is 200. Using a larger value may help in achieving a better recall, but will increase the time needed to add vectors to the set.
explorationFactor - the exploration factor for the vector search (default: 200).thispublic VAddArgs maxNodes(Long maxNodes)
The M option specifies the maximum number of connections that each node of the graph will have with other nodes.
The default is 16. More connections means more memory, but provides for more efficient graph exploration. Nodes at layer zero (every node exists at least at layer zero) have M * 2 connections, while the other layers only have M connections.
If you don't have a recall quality problem, the default is acceptable and uses a minimal amount of memory.
maxNodes - the maximum number of connections per node (default: 16).thispublic VAddArgs attributes(String attributes)
The SETATTR option associates attributes in the form of a JavaScript object to the newly created entry or updates the attributes (if they already exist). It is the same as calling the VSETATTR command separately.
Attributes can be used for filtering during similarity searches with the VSIM command.
Example: attributes(Arrays.asList("{\"color\":\"red\",\"price\":25}"))
attributes - the attributes for the vector as JSON strings.thispublic VAddArgs attributes(JsonValue attributes)
JsonValue object.
The SETATTR option associates attributes in the form of a JavaScript object to the newly created entry or updates the attributes (if they already exist). It is the same as calling the VSETATTR command separately.
Attributes can be used for filtering during similarity searches with the VSIM command.
attributes - the attributes for the vector as JSON strings.thispublic <K,V> void build(CommandArgs<K,V> args)
VAddArgs instance.
This method is called internally by the Redis client to construct the VADD command with all the specified options. It adds each option that has been set to the command arguments in the correct format.
build in interface CompositeArgumentK - Key type.V - Value type.args - Command arguments to which the VADD options will be added.Copyright © 2025 lettuce.io. All rights reserved.