@@ -60,7 +60,7 @@ Start by adding the point vectors to a set called `points` using
60
60
The [ ` TYPE ` ] ({{< relref "/commands/type" >}}) command returns a type of ` vectorset `
61
61
for this object.
62
62
63
- ```
63
+ {{< clients-example vecset_tutorial vadd >}}
64
64
> VADD points VALUES 2 1.0 1.0 pt: A
65
65
(integer) 1
66
66
> VADD points VALUES 2 -1.0 -1.0 pt: B
@@ -73,26 +73,27 @@ for this object.
73
73
(integer) 1
74
74
> TYPE points
75
75
vectorset
76
- ```
76
+ {{< /clients-example >}}
77
+
77
78
78
79
Get the number of elements in the set (also known as the * cardinality* of the set)
79
80
using [ ` VCARD ` ] ({{< relref "/commands/vcard" >}}) and the number of dimensions of
80
81
the vectors using [ ` VDIM ` ] ({{< relref "/commands/vdim" >}}):
81
82
82
- ```
83
+ {{< clients-example vecset_tutorial vcardvdim >}}
83
84
> VCARD points
84
85
(integer) 5
85
86
> VDIM points
86
87
(integer) 2
87
- ```
88
+ {{< /clients-example >}}
88
89
89
90
Get the coordinate values from the elements using [ ` VEMB ` ] ({{< relref "/commands/vemb" >}}).
90
91
Note that the values will not typically be the exact values you supplied when you added
91
92
the vector because
92
93
[ quantization] ({{< relref "/develop/data-types/vector-sets/performance#quantization-effects" >}})
93
94
is applied to improve performance.
94
95
95
- ```
96
+ {{< clients-example vecset_tutorial vemb >}}
96
97
> VEMB points pt: A
97
98
1 ) "0.9999999403953552"
98
99
2 ) "0.9999999403953552"
@@ -108,14 +109,14 @@ is applied to improve performance.
108
109
> VEMB points pt: E
109
110
1 ) "1"
110
111
2 ) "0"
111
- ```
112
+ {{< /clients-example >}}
112
113
113
114
Set and retrieve an element's JSON attribute data using
114
115
[ ` VSETATTR ` ] ({{< relref "/commands/vsetattr" >}})
115
116
and [ ` VGETATTR ` ] ({{< relref "/commands/vgetattr" >}}). You can also pass an empty string
116
117
to ` VSETATTR ` to delete the attribute data:
117
118
118
- ```
119
+ {{< clients-example vecset_tutorial attr >}}
119
120
> VSETATTR points pt: A "{\" name\" : \" Point A\" , \" description\" : \" First point added\" }"
120
121
(integer) 1
121
122
> VGETATTR points pt: A
@@ -124,11 +125,11 @@ to `VSETATTR` to delete the attribute data:
124
125
(integer) 1
125
126
> VGETATTR points pt: A
126
127
(nil)
127
- ```
128
+ {{< /clients-example >}}
128
129
129
130
Remove an unwanted element with [ ` VREM ` ] ({{< relref "/commands/vrem" >}})
130
131
131
- ```
132
+ {{< clients-example vecset_tutorial vrem >}}
132
133
> VADD points VALUES 2 0 0 pt: F
133
134
(integer) 1
134
135
127.0.0.1:6379> VCARD points
@@ -137,24 +138,24 @@ Remove an unwanted element with [`VREM`]({{< relref "/commands/vrem" >}})
137
138
(integer) 1
138
139
127.0.0.1:6379> VCARD points
139
140
(integer) 5
140
- ```
141
+ {{< /clients-example >}}
141
142
142
143
### Vector similarity search
143
144
144
145
Use [ ` VSIM ` ] ({{< relref "/commands/vsim" >}}) to rank the points in order of their vector distance from a sample point:
145
146
146
- ```
147
+ {{< clients-example vecset_tutorial vsim_basic >}}
147
148
> VSIM points values 2 0.9 0.1
148
149
1 ) "pt: E "
149
150
2 ) "pt: A "
150
151
3 ) "pt: D "
151
152
4 ) "pt: C "
152
153
5 ) "pt: B "
153
- ```
154
+ {{< /clients-example >}}
154
155
155
156
Find the four elements that are closest to point A and show their distance "scores":
156
157
157
- ```
158
+ {{< clients-example vecset_tutorial vsim_options >}}
158
159
> VSIM points ELE pt: A WITHSCORES COUNT 4
159
160
1 ) "pt: A "
160
161
2 ) "1"
@@ -164,13 +165,13 @@ Find the four elements that are closest to point A and show their distance "scor
164
165
6 ) "0.5"
165
166
7 ) "pt: D "
166
167
8 ) "0.5"
167
- ```
168
+ {{< /clients-example >}}
168
169
169
170
Add some JSON attributes and use
170
171
[ filter expressions] ({{< relref "/develop/data-types/vector-sets/filtered-search" >}})
171
172
to include them in the search:
172
173
173
- ```
174
+ {{< clients-example vecset_tutorial vsim_filter >}}
174
175
> VSETATTR points pt: A "{\" size\" :\" large\" ,\" price\" : 18.99}"
175
176
(integer) 1
176
177
> VSETATTR points pt: B "{\" size\" :\" large\" ,\" price\" : 35.99}"
@@ -194,7 +195,7 @@ to include them in the search:
194
195
> VSIM points ELE pt: A FILTER '.size == "large" && .price > 20.00'
195
196
1 ) "pt: C "
196
197
2 ) "pt: B "
197
- ```
198
+ {{< /clients-example >}}
198
199
199
200
## More information
200
201
0 commit comments