|
1 | 1 | { |
2 | 2 | "cells": [ |
3 | 3 | { |
| 4 | + "attachments": {}, |
4 | 5 | "cell_type": "markdown", |
5 | 6 | "metadata": {}, |
6 | 7 | "source": [ |
|
21 | 22 | ] |
22 | 23 | }, |
23 | 24 | { |
| 25 | + "attachments": {}, |
24 | 26 | "cell_type": "markdown", |
25 | 27 | "metadata": {}, |
26 | 28 | "source": [ |
|
31 | 33 | }, |
32 | 34 | { |
33 | 35 | "cell_type": "code", |
34 | | - "execution_count": 2, |
| 36 | + "execution_count": 1, |
35 | 37 | "metadata": {}, |
36 | 38 | "outputs": [], |
37 | 39 | "source": [ |
|
49 | 51 | ] |
50 | 52 | }, |
51 | 53 | { |
| 54 | + "attachments": {}, |
52 | 55 | "cell_type": "markdown", |
53 | 56 | "metadata": {}, |
54 | 57 | "source": [ |
|
61 | 64 | }, |
62 | 65 | { |
63 | 66 | "cell_type": "code", |
64 | | - "execution_count": 3, |
| 67 | + "execution_count": 2, |
65 | 68 | "metadata": {}, |
66 | 69 | "outputs": [ |
67 | 70 | { |
|
133 | 136 | "2 b'fff?fff?\\xcd\\xcc\\xcc=' " |
134 | 137 | ] |
135 | 138 | }, |
136 | | - "execution_count": 3, |
| 139 | + "execution_count": 2, |
137 | 140 | "metadata": {}, |
138 | 141 | "output_type": "execute_result" |
139 | 142 | } |
|
148 | 151 | ] |
149 | 152 | }, |
150 | 153 | { |
| 154 | + "attachments": {}, |
151 | 155 | "cell_type": "markdown", |
152 | 156 | "metadata": {}, |
153 | 157 | "source": [ |
|
157 | 161 | ] |
158 | 162 | }, |
159 | 163 | { |
| 164 | + "attachments": {}, |
160 | 165 | "cell_type": "markdown", |
161 | 166 | "metadata": {}, |
162 | 167 | "source": [ |
|
179 | 184 | }, |
180 | 185 | { |
181 | 186 | "cell_type": "code", |
182 | | - "execution_count": 4, |
| 187 | + "execution_count": 3, |
183 | 188 | "metadata": {}, |
184 | 189 | "outputs": [], |
185 | 190 | "source": [ |
|
191 | 196 | " \"storage_type\": \"hash\",\n", |
192 | 197 | " },\n", |
193 | 198 | " \"fields\": {\n", |
194 | | - " # key is the field type\n", |
195 | | - " # value is the name of the column in the dataset(frame)\n", |
196 | | - " \"tag\": {\"credit_score\": {}},\n", |
197 | | - " \"text\": {\"job\": {}},\n", |
198 | | - " \"numeric\": {\"age\": {}},\n", |
199 | | - " \"vector\": {\n", |
200 | | - " \"user_embedding\": {\n", |
| 199 | + " \"tag\": [{\"name\": \"credit_score\"}],\n", |
| 200 | + " \"text\": [{\"name\": \"job\"}],\n", |
| 201 | + " \"numeric\": [{\"name\": \"age\"}],\n", |
| 202 | + " \"vector\": [{\n", |
| 203 | + " \"name\": \"user_embedding\",\n", |
201 | 204 | " \"dims\": 3,\n", |
202 | 205 | " \"distance_metric\": \"cosine\",\n", |
203 | 206 | " \"algorithm\": \"flat\",\n", |
204 | | - " \"datatype\": \"float32\",\n", |
205 | | - " }\n", |
206 | | - " },\n", |
| 207 | + " \"datatype\": \"float32\"}\n", |
| 208 | + " ]\n", |
207 | 209 | " },\n", |
208 | | - "}" |
| 210 | + "}\n" |
209 | 211 | ] |
210 | 212 | }, |
211 | 213 | { |
| 214 | + "attachments": {}, |
212 | 215 | "cell_type": "markdown", |
213 | 216 | "metadata": {}, |
214 | 217 | "source": [ |
|
221 | 224 | }, |
222 | 225 | { |
223 | 226 | "cell_type": "code", |
224 | | - "execution_count": 5, |
| 227 | + "execution_count": 4, |
225 | 228 | "metadata": {}, |
226 | 229 | "outputs": [], |
227 | 230 | "source": [ |
|
231 | 234 | "index = SearchIndex.from_dict(schema)\n", |
232 | 235 | "\n", |
233 | 236 | "# connect to local redis instance\n", |
234 | | - "index.connect(\"localhost\", 6379)\n", |
| 237 | + "index.connect(\"redis://localhost:6379\")\n", |
235 | 238 | "\n", |
236 | 239 | "# create the index (no data yet)\n", |
237 | 240 | "index.create()" |
238 | 241 | ] |
239 | 242 | }, |
240 | 243 | { |
| 244 | + "cell_type": "code", |
| 245 | + "execution_count": 5, |
| 246 | + "metadata": {}, |
| 247 | + "outputs": [ |
| 248 | + { |
| 249 | + "name": "stdout", |
| 250 | + "output_type": "stream", |
| 251 | + "text": [ |
| 252 | + "\u001b[32m17:14:25\u001b[0m \u001b[35msam.partee-NW9MQX5Y74\u001b[0m \u001b[34mredisvl.cli.index[58677]\u001b[0m \u001b[1;30mINFO\u001b[0m Indices:\n", |
| 253 | + "\u001b[32m17:14:25\u001b[0m \u001b[35msam.partee-NW9MQX5Y74\u001b[0m \u001b[34mredisvl.cli.index[58677]\u001b[0m \u001b[1;30mINFO\u001b[0m 1. user_index\n" |
| 254 | + ] |
| 255 | + } |
| 256 | + ], |
| 257 | + "source": [ |
| 258 | + "# use the CLI to see the created index\n", |
| 259 | + "!redisvl index listall" |
| 260 | + ] |
| 261 | + }, |
| 262 | + { |
| 263 | + "attachments": {}, |
241 | 264 | "cell_type": "markdown", |
242 | 265 | "metadata": {}, |
243 | 266 | "source": [ |
|
262 | 285 | ] |
263 | 286 | }, |
264 | 287 | { |
| 288 | + "attachments": {}, |
265 | 289 | "cell_type": "markdown", |
266 | 290 | "metadata": {}, |
267 | 291 | "source": [ |
|
272 | 296 | }, |
273 | 297 | { |
274 | 298 | "cell_type": "code", |
275 | | - "execution_count": 8, |
| 299 | + "execution_count": 7, |
276 | 300 | "metadata": {}, |
277 | 301 | "outputs": [], |
278 | 302 | "source": [ |
|
297 | 321 | }, |
298 | 322 | { |
299 | 323 | "cell_type": "code", |
300 | | - "execution_count": 9, |
| 324 | + "execution_count": 8, |
301 | 325 | "metadata": {}, |
302 | 326 | "outputs": [ |
303 | 327 | { |
304 | 328 | "name": "stdout", |
305 | 329 | "output_type": "stream", |
306 | 330 | "text": [ |
307 | 331 | "Score: 0\n", |
308 | | - "Document {'id': 'user:john', 'payload': None, 'vector_score': '0', 'users': 'john', 'age': '1', 'job': 'engineer', 'credit_score': 'high'}\n", |
| 332 | + "Document {'id': 'user::john', 'payload': None, 'vector_score': '0', 'users': 'john', 'age': '1', 'job': 'engineer', 'credit_score': 'high'}\n", |
309 | 333 | "Score: 0\n", |
310 | | - "Document {'id': 'user:mary', 'payload': None, 'vector_score': '0', 'users': 'mary', 'age': '2', 'job': 'doctor', 'credit_score': 'low'}\n", |
| 334 | + "Document {'id': 'user::mary', 'payload': None, 'vector_score': '0', 'users': 'mary', 'age': '2', 'job': 'doctor', 'credit_score': 'low'}\n", |
311 | 335 | "Score: 0.653301358223\n", |
312 | | - "Document {'id': 'user:joe', 'payload': None, 'vector_score': '0.653301358223', 'users': 'joe', 'age': '3', 'job': 'dentist', 'credit_score': 'medium'}\n" |
| 336 | + "Document {'id': 'user::joe', 'payload': None, 'vector_score': '0.653301358223', 'users': 'joe', 'age': '3', 'job': 'dentist', 'credit_score': 'medium'}\n" |
313 | 337 | ] |
314 | 338 | } |
315 | 339 | ], |
|
0 commit comments