Skip to content

Commit 3fabf0b

Browse files
committed
DOC-5818: vector set: add new VRANGE command
1 parent cab5aa7 commit 3fabf0b

File tree

14 files changed

+126
-14
lines changed

14 files changed

+126
-14
lines changed

content/commands/vadd.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ since: 8.0.0
1818
summary: Add a new element to a vector set, or update its vector if it already exists.
1919
syntax_fmt: "VADD key [REDUCE dim] (FP32 | VALUES num) vector element [CAS] [NOQUANT | Q8 | BIN]\n [EF build-exploration-factor] [SETATTR attributes] [M numlinks]"
2020
title: VADD
21-
bannerText: Vector set is a new data type that is currently in preview and may be subject to change.
2221
---
2322

2423
Add a new element into the vector set specified by `key`. The vector can be provided as 32-bit floating point (`FP32`) blob of values, or as floating point numbers as strings, prefixed by the number of elements (3 in the example below):

content/commands/vcard.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ since: 8.0.0
1818
summary: Return the number of elements in a vector set.
1919
syntax_fmt: "VCARD key"
2020
title: VCARD
21-
bannerText: Vector set is a new data type that is currently in preview and may be subject to change.
2221
---
2322

2423
Return the number of elements in the specified vector set.

content/commands/vdim.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ since: 8.0.0
1818
summary: Return the dimension of vectors in the vector set.
1919
syntax_fmt: "VDIM key"
2020
title: VDIM
21-
bannerText: Vector set is a new data type that is currently in preview and may be subject to change.
2221
---
2322

2423
Return the number of dimensions of the vectors in the specified vector set.

content/commands/vemb.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ since: 8.0.0
1818
summary: Return the vector associated with an element.
1919
syntax_fmt: "VEMB key element [RAW]"
2020
title: VEMB
21-
bannerText: Vector set is a new data type that is currently in preview and may be subject to change.
2221
---
2322

2423
Return the approximate vector associated with a given element in the vector set.

content/commands/vgetattr.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ since: 8.0.0
1818
summary: Retrieve the JSON attributes of elements.
1919
syntax_fmt: "VGETATTR key element"
2020
title: VGETATTR
21-
bannerText: Vector set is a new data type that is currently in preview and may be subject to change.
2221
---
2322

2423
Return the JSON attributes associated with an element in a vector set.

content/commands/vinfo.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ since: 8.0.0
1818
summary: Return information about a vector set.
1919
syntax_fmt: "VINFO key"
2020
title: VINFO
21-
bannerText: Vector set is a new data type that is currently in preview and may be subject to change.
2221
---
2322

2423
Return metadata and internal details about a vector set, including size, dimensions, quantization type, and graph structure.

content/commands/vismember.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ summary: Check if an element exists in a vector set.
2828
syntax_fmt: VISMEMBER key element
2929
syntax_str: element
3030
title: VISMEMBER
31-
bannerText: Vector set is a new data type that is currently in preview and may be subject to change.
3231
---
3332

3433
Check if an element exists in a vector set.

content/commands/vlinks.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ since: 8.0.0
1818
summary: Return the neighbors of an element at each layer in the HNSW graph.
1919
syntax_fmt: "VLINKS key element [WITHSCORES]"
2020
title: VLINKS
21-
bannerText: Vector set is a new data type that is currently in preview and may be subject to change.
2221
---
2322

2423
Return the neighbors of a specified element in a vector set. The command shows the connections for each layer of the HNSW graph.

content/commands/vrandmember.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ since: 8.0.0
1818
summary: Return one or multiple random members from a vector set.
1919
syntax_fmt: "VRANDMEMBER key [count]"
2020
title: VRANDMEMBER
21-
bannerText: Vector set is a new data type that is currently in preview and may be subject to change.
2221
---
2322

2423
Return one or more random elements from a vector set.

content/commands/vrange.md

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
---
2+
arguments:
3+
- name: key
4+
type: key
5+
- name: start
6+
type: string
7+
- name: end
8+
type: string
9+
- name: count
10+
optional: true
11+
type: integer
12+
arity: -4
13+
categories:
14+
- docs
15+
- develop
16+
- stack
17+
- oss
18+
- rs
19+
- rc
20+
- oss
21+
- kubernetes
22+
- clients
23+
command_flags:
24+
- READONLY
25+
complexity: O(log(K)+M) where K is the number of elements in the start prefix, and
26+
M is the number of elements returned. In practical terms, the command is just O(M)
27+
description: Return elements in a lexicographical range
28+
function: vrangeCommand
29+
group: vector_set
30+
hidden: false
31+
linkTitle: VRANGE
32+
since: 8.4.0
33+
summary: Return elements in a lexicographical range
34+
syntax_fmt: VRANGE key start end [count]
35+
syntax_str: start end [count]
36+
title: VRANGE
37+
---
38+
The `VRANGE` command provides a stateless iterator for the elements inside a vector set. It allows you to retrieve all the elements inside a vector set in small amounts for each call, without an explicit cursor, and with guarantees about what you will miss in case the vector set is changing (elements added and/or removed) during the iteration.
39+
40+
The command returns elements in lexicographical order, using byte-by-byte comparison (like `memcmp()`) to establish a total order among elements.
41+
42+
## Required arguments
43+
44+
<details open><summary><code>key</code></summary>
45+
46+
The name of the vector set key from which to retrieve elements.
47+
48+
</details>
49+
50+
<details open><summary><code>start</code></summary>
51+
52+
The starting point of the lexicographical range. Can be:
53+
- A string prefixed with `[` for inclusive range (e.g., `[Redis`)
54+
- A string prefixed with `(` for exclusive range (e.g., `(a7`)
55+
- The special symbol `-` to indicate the minimum element
56+
57+
</details>
58+
59+
<details open><summary><code>end</code></summary>
60+
61+
The ending point of the lexicographical range. Can be:
62+
- A string prefixed with `[` for inclusive range
63+
- A string prefixed with `(` for exclusive range
64+
- The special symbol `+` to indicate the maximum element
65+
66+
</details>
67+
68+
## Optional arguments
69+
70+
<details open><summary><code>count</code></summary>
71+
72+
The maximum number of elements to return. If `count` is negative, the command returns all elements in the specified range (which may block the server for a long time with large sets).
73+
74+
</details>
75+
76+
## Examples
77+
78+
Retrieve the first 10 elements starting from the string "Redis" (inclusive):
79+
80+
```
81+
VRANGE word_embeddings [Redis + 10
82+
```
83+
84+
Iterate through all elements, 10 at a time:
85+
86+
```
87+
VRANGE mykey - + 10
88+
```
89+
90+
Continue iteration from the last element of the previous result (exclusive):
91+
92+
```
93+
VRANGE mykey (a7 + 10
94+
```
95+
96+
Return all elements in the set (use with caution):
97+
98+
```
99+
VRANGE mykey - + -1
100+
```
101+
102+
## Return information
103+
104+
{{< multitabs id="return-info"
105+
tab1="RESP2"
106+
tab2="RESP3" >}}
107+
108+
One of the following:
109+
110+
- [Array reply]({{< relref "/develop/reference/protocol-spec#arrays" >}}) of elements in lexicographical order within the specified range.
111+
- [Array reply]({{< relref "/develop/reference/protocol-spec#arrays" >}}) (empty array) if the key doesn't exist.
112+
113+
-tab-sep-
114+
115+
One of the following:
116+
117+
- [Array reply]({{< relref "/develop/reference/protocol-spec#arrays" >}}) of elements in lexicographical order within the specified range.
118+
- [Array reply]({{< relref "/develop/reference/protocol-spec#arrays" >}}) (empty array) if the key doesn't exist.
119+
120+
{{< /multitabs >}}
121+
122+
## Behavior
123+
124+
- **Iteration guarantees**: Each range will produce exactly the elements that were present in the range at the moment the `VRANGE` command was executed.
125+
- **Concurrent modifications**: Elements removed or added during iteration may or may not be returned, depending on when they were modified.
126+
- **Empty key**: If the key doesn't exist, returns an empty array.

0 commit comments

Comments
 (0)