Files
redis/modules/vector-sets/commands.json
Salvatore Sanfilippo 3de2fdad58 [vector sets] VRANGE implementation (#14235)
This is basically the Vector Set iteration primitive.
It exploits the underlying radix tree implementation.
The usage pattern is strongly reminiscent of other Redis commands doing
similar things.

The command usage is straightforward:

```
> VRANGE word_embeddings_int8 [Redis + 10
 1) "Redis"
 2) "Rediscover"
 3) "Rediscover_Ashland"
 4) "Rediscover_Northern_Ireland"
 5) "Rediscovered"
 6) "Rediscovered_Bookshop"
 7) "Rediscovering"
 8) "Rediscovering_God"
 9) "Rediscovering_Lost"
10) "Rediscovers"
```

The above command returns 10 (or less, if less are available in the
specified range) elements from "Redis" (inclusive) to the maximum
possible element. The comparison is performed byte by byte, as
`memcmp()` would do, in this way the elements have a total order. The
start and end range can be either a string, prefixed
by `[` or `(` (the prefix is mandatory) to tell the command if the range
is inclusive or exclusive, or can be the special symbols `-` and `+`
that means the maximum and minimum element.

More info can be found in the implementation itself and in the README
file change.

---------

Co-authored-by: debing.sun <debing.sun@redis.com>
2025-10-09 10:14:14 +08:00

447 lines
9.2 KiB
JSON

{
"VADD": {
"summary": "Add one or more elements to a vector set, or update its vector if it already exists",
"complexity": "O(log(N)) for each element added, where N is the number of elements in the vector set.",
"group": "vector_set",
"since": "8.0.0",
"arity": -5,
"function": "vaddCommand",
"arguments": [
{
"name": "key",
"type": "key"
},
{
"token": "REDUCE",
"name": "reduce",
"type": "block",
"optional": true,
"arguments": [
{
"name": "dim",
"type": "integer"
}
]
},
{
"name": "format",
"type": "oneof",
"arguments": [
{
"name": "fp32",
"type": "pure-token",
"token": "FP32"
},
{
"name": "values",
"type": "pure-token",
"token": "VALUES"
}
]
},
{
"name": "vector",
"type": "string"
},
{
"name": "element",
"type": "string"
},
{
"token": "CAS",
"name": "cas",
"type": "pure-token",
"optional": true
},
{
"name": "quant_type",
"type": "oneof",
"optional": true,
"arguments": [
{
"name": "noquant",
"type": "pure-token",
"token": "NOQUANT"
},
{
"name": "bin",
"type": "pure-token",
"token": "BIN"
},
{
"name": "q8",
"type": "pure-token",
"token": "Q8"
}
]
},
{
"token": "EF",
"name": "build-exploration-factor",
"type": "integer",
"optional": true
},
{
"token": "SETATTR",
"name": "attributes",
"type": "string",
"optional": true
},
{
"token": "M",
"name": "numlinks",
"type": "integer",
"optional": true
}
],
"command_flags": [
"WRITE",
"DENYOOM"
]
},
"VREM": {
"summary": "Remove an element from a vector set",
"complexity": "O(log(N)) for each element removed, where N is the number of elements in the vector set.",
"group": "vector_set",
"since": "8.0.0",
"arity": 3,
"function": "vremCommand",
"command_flags": [
"WRITE"
],
"arguments": [
{
"name": "key",
"type": "key"
},
{
"name": "element",
"type": "string"
}
]
},
"VSIM": {
"summary": "Return elements by vector similarity",
"complexity": "O(log(N)) where N is the number of elements in the vector set.",
"group": "vector_set",
"since": "8.0.0",
"arity": -4,
"function": "vsimCommand",
"command_flags": [
"READONLY"
],
"arguments": [
{
"name": "key",
"type": "key"
},
{
"name": "format",
"type": "oneof",
"arguments": [
{
"name": "ele",
"type": "pure-token",
"token": "ELE"
},
{
"name": "fp32",
"type": "pure-token",
"token": "FP32"
},
{
"name": "values",
"type": "pure-token",
"token": "VALUES"
}
]
},
{
"name": "vector_or_element",
"type": "string"
},
{
"token": "WITHSCORES",
"name": "withscores",
"type": "pure-token",
"optional": true
},
{
"token": "WITHATTRIBS",
"name": "withattribs",
"type": "pure-token",
"optional": true
},
{
"token": "COUNT",
"name": "count",
"type": "integer",
"optional": true
},
{
"token": "EPSILON",
"name": "max_distance",
"type": "double",
"optional": true
},
{
"token": "EF",
"name": "search-exploration-factor",
"type": "integer",
"optional": true
},
{
"token": "FILTER",
"name": "expression",
"type": "string",
"optional": true
},
{
"token": "FILTER-EF",
"name": "max-filtering-effort",
"type": "integer",
"optional": true
},
{
"token": "TRUTH",
"name": "truth",
"type": "pure-token",
"optional": true
},
{
"token": "NOTHREAD",
"name": "nothread",
"type": "pure-token",
"optional": true
}
]
},
"VDIM": {
"summary": "Return the dimension of vectors in the vector set",
"complexity": "O(1)",
"group": "vector_set",
"since": "8.0.0",
"arity": 2,
"function": "vdimCommand",
"command_flags": [
"READONLY",
"FAST"
],
"arguments": [
{
"name": "key",
"type": "key"
}
]
},
"VCARD": {
"summary": "Return the number of elements in a vector set",
"complexity": "O(1)",
"group": "vector_set",
"since": "8.0.0",
"arity": 2,
"function": "vcardCommand",
"command_flags": [
"READONLY",
"FAST"
],
"arguments": [
{
"name": "key",
"type": "key"
}
]
},
"VEMB": {
"summary": "Return the vector associated with an element",
"complexity": "O(1)",
"group": "vector_set",
"since": "8.0.0",
"arity": -3,
"function": "vembCommand",
"command_flags": [
"READONLY"
],
"arguments": [
{
"name": "key",
"type": "key"
},
{
"name": "element",
"type": "string"
},
{
"token": "RAW",
"name": "raw",
"type": "pure-token",
"optional": true
}
]
},
"VLINKS": {
"summary": "Return the neighbors of an element at each layer in the HNSW graph",
"complexity": "O(1)",
"group": "vector_set",
"since": "8.0.0",
"arity": -3,
"function": "vlinksCommand",
"command_flags": [
"READONLY"
],
"arguments": [
{
"name": "key",
"type": "key"
},
{
"name": "element",
"type": "string"
},
{
"token": "WITHSCORES",
"name": "withscores",
"type": "pure-token",
"optional": true
}
]
},
"VINFO": {
"summary": "Return information about a vector set",
"complexity": "O(1)",
"group": "vector_set",
"since": "8.0.0",
"arity": 2,
"function": "vinfoCommand",
"command_flags": [
"READONLY",
"FAST"
],
"arguments": [
{
"name": "key",
"type": "key"
}
]
},
"VSETATTR": {
"summary": "Associate or remove the JSON attributes of elements",
"complexity": "O(1)",
"group": "vector_set",
"since": "8.0.0",
"arity": 4,
"function": "vsetattrCommand",
"command_flags": [
"WRITE"
],
"arguments": [
{
"name": "key",
"type": "key"
},
{
"name": "element",
"type": "string"
},
{
"name": "json",
"type": "string"
}
]
},
"VGETATTR": {
"summary": "Retrieve the JSON attributes of elements",
"complexity": "O(1)",
"group": "vector_set",
"since": "8.0.0",
"arity": 3,
"function": "vgetattrCommand",
"command_flags": [
"READONLY"
],
"arguments": [
{
"name": "key",
"type": "key"
},
{
"name": "element",
"type": "string"
}
]
},
"VRANDMEMBER": {
"summary": "Return one or multiple random members from a vector set",
"complexity": "O(N) where N is the absolute value of the count argument.",
"group": "vector_set",
"since": "8.0.0",
"arity": -2,
"function": "vrandmemberCommand",
"command_flags": [
"READONLY"
],
"arguments": [
{
"name": "key",
"type": "key"
},
{
"name": "count",
"type": "integer",
"optional": true
}
]
},
"VISMEMBER": {
"summary": "Check if an element exists in a vector set",
"complexity": "O(1)",
"group": "vector_set",
"since": "8.2.0",
"arity": 3,
"function": "vismemberCommand",
"command_flags": [
"READONLY"
],
"arguments": [
{
"name": "key",
"type": "key"
},
{
"name": "element",
"type": "string"
}
]
},
"VRANGE": {
"summary": "Return elements in a lexicographical range",
"complexity": "O(log(K)+M) where K is the number of elements in the start prefix, and M is the number of elements returned. In practical terms, the command is just O(M)",
"group": "vector_set",
"since": "8.4.0",
"arity": -4,
"function": "vrangeCommand",
"command_flags": [
"READONLY"
],
"arguments": [
{
"name": "key",
"type": "key"
},
{
"name": "start",
"type": "string"
},
{
"name": "end",
"type": "string"
},
{
"name": "count",
"type": "integer",
"optional": true
}
]
}
}