Skip to content

Commit c39d562

Browse files
dalaoqirueian
andauthored
Add Vector Sets commands json (#827)
* feat: Add Vector Sets commands Signed-off-by: Tsung-Han Ho (dalaoqi) <[email protected]> * feat: Add Vector Sets commands Signed-off-by: Rueian <[email protected]> --------- Signed-off-by: Tsung-Han Ho (dalaoqi) <[email protected]> Signed-off-by: Rueian <[email protected]> Co-authored-by: Rueian <[email protected]>
1 parent 953d4ae commit c39d562

File tree

4 files changed

+1381
-1
lines changed

4 files changed

+1381
-1
lines changed
Lines changed: 354 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,354 @@
1+
{
2+
"VADD": {
3+
"summary": "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",
4+
"since": "Redis CE 8.0.0",
5+
"group": "vector_set",
6+
"complexity": "O(log(N)) for each element added, where N is the number of elements in the vector set.",
7+
"arguments": [
8+
{
9+
"name": "key",
10+
"type": "key"
11+
},
12+
{
13+
"command": "REDUCE",
14+
"name": "dim",
15+
"type": "integer",
16+
"optional": true
17+
},
18+
{
19+
"name": "num",
20+
"type": "oneof",
21+
"arguments": [
22+
{
23+
"type": "block",
24+
"arguments": [
25+
{
26+
"name": "FP32",
27+
"type": "pure-token",
28+
"token": "FP32"
29+
},
30+
{
31+
"name": "vector",
32+
"type": "string"
33+
}
34+
]
35+
},
36+
{
37+
"type": "block",
38+
"arguments": [
39+
{
40+
"command": "VALUES",
41+
"name": "num",
42+
"type": "integer"
43+
},
44+
{
45+
"name": "vector",
46+
"type": "float32",
47+
"multiple": true
48+
}
49+
]
50+
}
51+
]
52+
},
53+
{
54+
"name": "element",
55+
"type": "string"
56+
},
57+
{
58+
"name": "CAS",
59+
"type": "pure-token",
60+
"token": "CAS",
61+
"optional": true
62+
},
63+
{
64+
"name": "quantization",
65+
"type": "oneof",
66+
"arguments": [
67+
{
68+
"name": "noquant",
69+
"type": "pure-token",
70+
"token": "NOQUANT"
71+
},
72+
{
73+
"name": "q8",
74+
"type": "pure-token",
75+
"token": "Q8"
76+
},
77+
{
78+
"name": "bin",
79+
"type": "pure-token",
80+
"token": "BIN"
81+
}
82+
],
83+
"optional": true
84+
},
85+
{
86+
"command": "EF",
87+
"name": "build-exploration-factor",
88+
"type": "integer",
89+
"optional": true
90+
},
91+
{
92+
"command": "SETATTR",
93+
"name": "attributes",
94+
"type": "string",
95+
"optional": true
96+
},
97+
{
98+
"command": "M",
99+
"name": "numlinks",
100+
"type": "integer",
101+
"optional": true
102+
}
103+
]
104+
},
105+
"VCARD": {
106+
"summary": "Return the number of elements in the specified vector set.",
107+
"since": "Redis CE 8.0.0",
108+
"group": "vector_set",
109+
"complexity": "O(1)",
110+
"arguments": [
111+
{
112+
"name": "key",
113+
"type": "key"
114+
}
115+
]
116+
},
117+
"VDIM": {
118+
"summary": "Return the number of dimensions of the vectors in the specified vector set.",
119+
"since": "Redis CE 8.0.0",
120+
"group": "vector_set",
121+
"complexity": "O(1)",
122+
"arguments": [
123+
{
124+
"name": "key",
125+
"type": "key"
126+
}
127+
]
128+
},
129+
"VEMB": {
130+
"summary": "Return the approximate vector associated with a given element in the vector set.",
131+
"since": "Redis CE 8.0.0",
132+
"group": "vector_set",
133+
"complexity": "O(1)",
134+
"arguments": [
135+
{
136+
"name": "key",
137+
"type": "key"
138+
},
139+
{
140+
"name": "element",
141+
"type": "string"
142+
},
143+
{
144+
"command": "RAW",
145+
"type": "command",
146+
"optional": true
147+
}
148+
]
149+
},
150+
"VGETATTR": {
151+
"summary": "Return the JSON attributes associated with an element in a vector set.",
152+
"since": "Redis CE 8.0.0",
153+
"group": "vector_set",
154+
"complexity": "O(1)",
155+
"arguments": [
156+
{
157+
"name": "key",
158+
"type": "key"
159+
},
160+
{
161+
"name": "element",
162+
"type": "string"
163+
}
164+
]
165+
},
166+
"VINFO": {
167+
"summary": "Return metadata and internal details about a vector set, including size, dimensions, quantization type, and graph structure.",
168+
"since": "Redis CE 8.0.0",
169+
"group": "vector_set",
170+
"complexity": "O(1)",
171+
"arguments": [
172+
{
173+
"name": "key",
174+
"type": "key"
175+
}
176+
]
177+
},
178+
"VLINKS": {
179+
"summary": "Return the neighbors of a specified element in a vector set. The command shows the connections for each layer of the HNSW graph.",
180+
"since": "Redis CE 8.0.0",
181+
"group": "vector_set",
182+
"complexity": "O(1)",
183+
"arguments": [
184+
{
185+
"name": "key",
186+
"type": "key"
187+
},
188+
{
189+
"name": "element",
190+
"type": "string"
191+
},
192+
{
193+
"command": "WITHSCORES",
194+
"type": "command",
195+
"optional": true
196+
}
197+
]
198+
},
199+
"VRANDMEMBER": {
200+
"summary": "Return one or more random elements from a vector set.",
201+
"since": "Redis CE 8.0.0",
202+
"group": "vector_set",
203+
"complexity": "O(N) where N is the absolute value of the count argument.",
204+
"arguments": [
205+
{
206+
"name": "key",
207+
"type": "key"
208+
},
209+
{
210+
"name": "count",
211+
"type": "integer",
212+
"optional": true
213+
}
214+
]
215+
},
216+
"VREM": {
217+
"summary": "Remove an element from a vector set.",
218+
"since": "Redis CE 8.0.0",
219+
"group": "vector_set",
220+
"complexity": "O(log(N)) for each element removed, where N is the number of elements in the vector set.",
221+
"arguments": [
222+
{
223+
"name": "key",
224+
"type": "key"
225+
},
226+
{
227+
"name": "element",
228+
"type": "string"
229+
}
230+
]
231+
},
232+
"VSETATTR": {
233+
"summary": "Associate a JSON object with an element in a vector set. Use this command to store attributes that can be used in filtered similarity searches with VSIM.",
234+
"since": "Redis CE 8.0.0",
235+
"group": "vector_set",
236+
"complexity": "O(1)",
237+
"arguments": [
238+
{
239+
"name": "key",
240+
"type": "key"
241+
},
242+
{
243+
"name": "element",
244+
"type": "string"
245+
},
246+
{
247+
"name": "JSON",
248+
"type": "json_string"
249+
}
250+
]
251+
},
252+
"VSIM": {
253+
"summary": "Return elements similar to a given vector or element. Use this command to perform approximate or exact similarity searches within a vector set.",
254+
"since": "Redis CE 8.0.0",
255+
"group": "vector_set",
256+
"complexity": "O(log(N)) where N is the number of elements in the vector set.",
257+
"arguments": [
258+
{
259+
"name": "key",
260+
"type": "key"
261+
},
262+
{
263+
"name": "query_type",
264+
"type": "oneof",
265+
"arguments": [
266+
{
267+
"type": "block",
268+
"arguments": [
269+
{
270+
"name": "ELE",
271+
"type": "pure-token",
272+
"token": "ELE"
273+
},
274+
{
275+
"name": "element",
276+
"type": "string"
277+
}
278+
]
279+
},
280+
{
281+
"type": "block",
282+
"arguments": [
283+
{
284+
"name": "FP32",
285+
"type": "pure-token",
286+
"token": "FP32"
287+
},
288+
{
289+
"name": "vector",
290+
"type": "string"
291+
}
292+
]
293+
},
294+
{
295+
"type": "block",
296+
"arguments": [
297+
{
298+
"command": "VALUES",
299+
"name": "num",
300+
"type": "integer"
301+
},
302+
{
303+
"name": "vector",
304+
"type": "float32",
305+
"multiple": true
306+
}
307+
]
308+
}
309+
]
310+
},
311+
{
312+
"command": "WITHSCORES",
313+
"type": "command",
314+
"optional": true
315+
},
316+
{
317+
"command": "COUNT",
318+
"name": "num",
319+
"type": "integer",
320+
"optional": true
321+
},
322+
{
323+
"command": "EF",
324+
"name": "search-exploration-factor",
325+
"type": "integer",
326+
"optional": true
327+
},
328+
{
329+
"command": "FILTER",
330+
"name": "expression",
331+
"type": "string",
332+
"optional": true
333+
},
334+
{
335+
"command": "FILTER-EF",
336+
"name": "max-filtering-effort",
337+
"type": "integer",
338+
"optional": true
339+
},
340+
{
341+
"name": "TRUTH",
342+
"type": "pure-token",
343+
"token": "TRUTH",
344+
"optional": true
345+
},
346+
{
347+
"name": "NOTHREAD",
348+
"type": "pure-token",
349+
"token": "NOTHREAD",
350+
"optional": true
351+
}
352+
]
353+
}
354+
}

hack/cmds/gen.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -677,10 +677,12 @@ func toGoType(paramType string) string {
677677
return "[]string"
678678
case "...string": // TODO hack for FT.CREATE VECTOR
679679
return "...string"
680-
case "key", "string", "pattern", "type":
680+
case "key", "string", "pattern", "type", "json_string":
681681
return "string"
682682
case "double":
683683
return "float64"
684+
case "float32":
685+
return "float32"
684686
case "integer", "posix time", "unix-time":
685687
return "int64"
686688
case "unsigned integer":
@@ -870,6 +872,8 @@ func printBuilder(w io.Writer, parent, next goStruct) {
870872
switch toGoType(next.BuildDef.Parameters[0].Type) {
871873
case "float64":
872874
fmt.Fprintf(w, "\t\tc.cs.s = append(c.cs.s, strconv.FormatFloat(n, 'f', -1, 64))\n")
875+
case "float32":
876+
fmt.Fprintf(w, "\t\tc.cs.s = append(c.cs.s, strconv.FormatFloat(float64(n), 'f', -1, 64))\n")
873877
case "int64":
874878
fmt.Fprintf(w, "\t\tc.cs.s = append(c.cs.s, strconv.FormatInt(n, 10))\n")
875879
case "uint64":

0 commit comments

Comments
 (0)