Skip to content

Commit 592b79f

Browse files
Expand CLI usage examples and docs (#285)
1 parent 04db2fd commit 592b79f

File tree

1 file changed

+132
-47
lines changed

1 file changed

+132
-47
lines changed

docs/overview/cli.ipynb

Lines changed: 132 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@
1717
},
1818
{
1919
"cell_type": "code",
20-
"execution_count": 1,
20+
"execution_count": 30,
2121
"metadata": {},
2222
"outputs": [
2323
{
2424
"name": "stdout",
2525
"output_type": "stream",
2626
"text": [
27-
"\u001b[32m15:02:39\u001b[0m \u001b[34m[RedisVL]\u001b[0m \u001b[1;30mINFO\u001b[0m RedisVL version 0.3.9\n"
27+
"\u001b[32m18:12:25\u001b[0m \u001b[34m[RedisVL]\u001b[0m \u001b[1;30mINFO\u001b[0m RedisVL version 0.3.9\n"
2828
]
2929
}
3030
],
@@ -33,6 +33,25 @@
3333
"!rvl version"
3434
]
3535
},
36+
{
37+
"cell_type": "markdown",
38+
"metadata": {},
39+
"source": [
40+
"## Commands\n",
41+
"Here's a table of all the rvl commands and options. We'll go into each one in detail below.\n",
42+
"\n",
43+
"| Command | Options | Description |\n",
44+
"|---------------|--------------------------|-------------|\n",
45+
"| `rvl version` | | display the redisvl library version|\n",
46+
"| `rvl index` | `create --schema` or `-s <schema.yaml>`| create a redis index from the specified schema file|\n",
47+
"| `rvl index` | `listall` | list all the existing search indices|\n",
48+
"| `rvl index` | `info --index` or ` -i <index_name>` | display the index definition in tabular format|\n",
49+
"| `rvl index` | `delete --index` or `-i <index_name>` | remove the specified index, leaving the data still in Redis|\n",
50+
"| `rvl index` | `destroy --index` or `-i <index_name>`| remove the specified index, as well as the associated data|\n",
51+
"| `rvl stats` | `--index` or `-i <index_name>` | display the index statistics, including number of docs, average bytes per record, indexing time, etc|\n",
52+
"| `rvl stats` | `--schema` or `-s <schema.yaml>` | display the index statistics of a schema defined in <schema.yaml>. The index must have already been created within Redis|"
53+
]
54+
},
3655
{
3756
"cell_type": "markdown",
3857
"metadata": {},
@@ -46,7 +65,7 @@
4665
},
4766
{
4867
"cell_type": "code",
49-
"execution_count": 2,
68+
"execution_count": 31,
5069
"metadata": {},
5170
"outputs": [
5271
{
@@ -80,14 +99,15 @@
8099
},
81100
{
82101
"cell_type": "code",
83-
"execution_count": 3,
102+
"execution_count": 32,
84103
"metadata": {},
85104
"outputs": [
86105
{
87106
"name": "stdout",
88107
"output_type": "stream",
89108
"text": [
90-
"\u001b[32m22:33:31\u001b[0m \u001b[34m[RedisVL]\u001b[0m \u001b[1;30mINFO\u001b[0m Index created successfully\n"
109+
"\u001b[32m18:12:32\u001b[0m \u001b[34m[RedisVL]\u001b[0m \u001b[1;30mINFO\u001b[0m Using Redis address from environment variable, REDIS_URL\n",
110+
"\u001b[32m18:12:32\u001b[0m \u001b[34m[RedisVL]\u001b[0m \u001b[1;30mINFO\u001b[0m Index created successfully\n"
91111
]
92112
}
93113
],
@@ -98,15 +118,16 @@
98118
},
99119
{
100120
"cell_type": "code",
101-
"execution_count": 4,
121+
"execution_count": 33,
102122
"metadata": {},
103123
"outputs": [
104124
{
105125
"name": "stdout",
106126
"output_type": "stream",
107127
"text": [
108-
"\u001b[32m22:33:33\u001b[0m \u001b[34m[RedisVL]\u001b[0m \u001b[1;30mINFO\u001b[0m Indices:\n",
109-
"\u001b[32m22:33:33\u001b[0m \u001b[34m[RedisVL]\u001b[0m \u001b[1;30mINFO\u001b[0m 1. vectorizers\n"
128+
"\u001b[32m18:12:35\u001b[0m \u001b[34m[RedisVL]\u001b[0m \u001b[1;30mINFO\u001b[0m Using Redis address from environment variable, REDIS_URL\n",
129+
"\u001b[32m18:12:35\u001b[0m \u001b[34m[RedisVL]\u001b[0m \u001b[1;30mINFO\u001b[0m Indices:\n",
130+
"\u001b[32m18:12:35\u001b[0m \u001b[34m[RedisVL]\u001b[0m \u001b[1;30mINFO\u001b[0m 1. vectorizers\n"
110131
]
111132
}
112133
],
@@ -117,13 +138,14 @@
117138
},
118139
{
119140
"cell_type": "code",
120-
"execution_count": 5,
141+
"execution_count": 34,
121142
"metadata": {},
122143
"outputs": [
123144
{
124145
"name": "stdout",
125146
"output_type": "stream",
126147
"text": [
148+
"\u001b[32m18:12:37\u001b[0m \u001b[34m[RedisVL]\u001b[0m \u001b[1;30mINFO\u001b[0m Using Redis address from environment variable, REDIS_URL\n",
127149
"\n",
128150
"\n",
129151
"Index Information:\n",
@@ -149,14 +171,15 @@
149171
},
150172
{
151173
"cell_type": "code",
152-
"execution_count": 6,
174+
"execution_count": 35,
153175
"metadata": {},
154176
"outputs": [
155177
{
156178
"name": "stdout",
157179
"output_type": "stream",
158180
"text": [
159-
"\u001b[32m22:33:36\u001b[0m \u001b[34m[RedisVL]\u001b[0m \u001b[1;30mINFO\u001b[0m Index deleted successfully\n"
181+
"\u001b[32m18:12:40\u001b[0m \u001b[34m[RedisVL]\u001b[0m \u001b[1;30mINFO\u001b[0m Using Redis address from environment variable, REDIS_URL\n",
182+
"\u001b[32m18:12:40\u001b[0m \u001b[34m[RedisVL]\u001b[0m \u001b[1;30mINFO\u001b[0m Index deleted successfully\n"
160183
]
161184
}
162185
],
@@ -167,19 +190,20 @@
167190
},
168191
{
169192
"cell_type": "code",
170-
"execution_count": 7,
193+
"execution_count": 36,
171194
"metadata": {},
172195
"outputs": [
173196
{
174197
"name": "stdout",
175198
"output_type": "stream",
176199
"text": [
177-
"\u001b[32m22:33:37\u001b[0m \u001b[34m[RedisVL]\u001b[0m \u001b[1;30mINFO\u001b[0m Indices:\n"
200+
"\u001b[32m18:12:43\u001b[0m \u001b[34m[RedisVL]\u001b[0m \u001b[1;30mINFO\u001b[0m Using Redis address from environment variable, REDIS_URL\n",
201+
"\u001b[32m18:12:43\u001b[0m \u001b[34m[RedisVL]\u001b[0m \u001b[1;30mINFO\u001b[0m Indices:\n"
178202
]
179203
}
180204
],
181205
"source": [
182-
"# see the index\n",
206+
"# see the indices that still exist\n",
183207
"!rvl index listall"
184208
]
185209
},
@@ -194,33 +218,37 @@
194218
},
195219
{
196220
"cell_type": "code",
197-
"execution_count": 8,
221+
"execution_count": 38,
198222
"metadata": {},
199223
"outputs": [
200224
{
201225
"name": "stdout",
202226
"output_type": "stream",
203227
"text": [
204-
"\u001b[32m22:33:40\u001b[0m \u001b[34m[RedisVL]\u001b[0m \u001b[1;30mINFO\u001b[0m Index created successfully\n"
228+
"\u001b[32m18:13:21\u001b[0m \u001b[34m[RedisVL]\u001b[0m \u001b[1;30mINFO\u001b[0m Using Redis address from environment variable, REDIS_URL\n",
229+
"\u001b[32m18:13:21\u001b[0m \u001b[34mredisvl.index.index\u001b[0m \u001b[1;30mINFO\u001b[0m Index already exists, not overwriting.\n",
230+
"\u001b[32m18:13:21\u001b[0m \u001b[34m[RedisVL]\u001b[0m \u001b[1;30mINFO\u001b[0m Index created successfully\n"
205231
]
206232
}
207233
],
208234
"source": [
209235
"# create a new index with the same schema\n",
236+
"# recreating the index will reindex the documents\n",
210237
"!rvl index create -s schema.yaml"
211238
]
212239
},
213240
{
214241
"cell_type": "code",
215-
"execution_count": 9,
242+
"execution_count": 39,
216243
"metadata": {},
217244
"outputs": [
218245
{
219246
"name": "stdout",
220247
"output_type": "stream",
221248
"text": [
222-
"\u001b[32m22:33:42\u001b[0m \u001b[34m[RedisVL]\u001b[0m \u001b[1;30mINFO\u001b[0m Indices:\n",
223-
"\u001b[32m22:33:42\u001b[0m \u001b[34m[RedisVL]\u001b[0m \u001b[1;30mINFO\u001b[0m 1. vectorizers\n"
249+
"\u001b[32m18:13:25\u001b[0m \u001b[34m[RedisVL]\u001b[0m \u001b[1;30mINFO\u001b[0m Using Redis address from environment variable, REDIS_URL\n",
250+
"\u001b[32m18:13:25\u001b[0m \u001b[34m[RedisVL]\u001b[0m \u001b[1;30mINFO\u001b[0m Indices:\n",
251+
"\u001b[32m18:13:25\u001b[0m \u001b[34m[RedisVL]\u001b[0m \u001b[1;30mINFO\u001b[0m 1. vectorizers\n"
224252
]
225253
}
226254
],
@@ -231,38 +259,39 @@
231259
},
232260
{
233261
"cell_type": "code",
234-
"execution_count": 10,
262+
"execution_count": 40,
235263
"metadata": {},
236264
"outputs": [
237265
{
238266
"name": "stdout",
239267
"output_type": "stream",
240268
"text": [
269+
"\u001b[32m18:13:31\u001b[0m \u001b[34m[RedisVL]\u001b[0m \u001b[1;30mINFO\u001b[0m Using Redis address from environment variable, REDIS_URL\n",
241270
"\n",
242271
"Statistics:\n",
243-
"╭─────────────────────────────┬────────────\n",
244-
"│ Stat Key │ Value \n",
245-
"├─────────────────────────────┼────────────\n",
246-
"│ num_docs │ 0 \n",
247-
"│ num_terms │ 0 \n",
248-
"│ max_doc_id │ 0 \n",
249-
"│ num_records │ 0 \n",
250-
"│ percent_indexed │ 1 \n",
251-
"│ hash_indexing_failures │ 0 \n",
252-
"│ number_of_uses │ 1 \n",
253-
"│ bytes_per_record_avg │ nan \n",
254-
"│ doc_table_size_mb │ 0 \n",
255-
"│ inverted_sz_mb │ 0 \n",
256-
"│ key_table_size_mb │ 0 \n",
257-
"│ offset_bits_per_record_avg │ nan \n",
258-
"│ offset_vectors_sz_mb │ 0 \n",
259-
"│ offsets_per_term_avg │ nan \n",
260-
"│ records_per_doc_avg │ nan \n",
261-
"│ sortable_values_size_mb │ 0 \n",
262-
"│ total_indexing_time │ 0 \n",
263-
"│ total_inverted_index_blocks │ 0 \n",
264-
"│ vector_index_sz_mb │ 0.00818634\n",
265-
"╰─────────────────────────────┴────────────\n"
272+
"╭─────────────────────────────┬─────────╮\n",
273+
"│ Stat Key │ Value │\n",
274+
"├─────────────────────────────┼─────────┤\n",
275+
"│ num_docs │ 0 │\n",
276+
"│ num_terms │ 0 │\n",
277+
"│ max_doc_id │ 0 │\n",
278+
"│ num_records │ 0 │\n",
279+
"│ percent_indexed │ 1 │\n",
280+
"│ hash_indexing_failures │ 3\n",
281+
"│ number_of_uses │ 2\n",
282+
"│ bytes_per_record_avg │ nan │\n",
283+
"│ doc_table_size_mb │ 0 │\n",
284+
"│ inverted_sz_mb │ 0 │\n",
285+
"│ key_table_size_mb │ 0 │\n",
286+
"│ offset_bits_per_record_avg │ nan │\n",
287+
"│ offset_vectors_sz_mb │ 0 │\n",
288+
"│ offsets_per_term_avg │ nan │\n",
289+
"│ records_per_doc_avg │ nan │\n",
290+
"│ sortable_values_size_mb │ 0 │\n",
291+
"│ total_indexing_time │ 0.02\n",
292+
"│ total_inverted_index_blocks │ 0 │\n",
293+
"│ vector_index_sz_mb │ 0 \n",
294+
"╰─────────────────────────────┴─────────╯\n"
266295
]
267296
}
268297
],
@@ -271,27 +300,83 @@
271300
"!rvl stats -i vectorizers"
272301
]
273302
},
303+
{
304+
"cell_type": "markdown",
305+
"metadata": {},
306+
"source": [
307+
"## Optional arguments\n",
308+
"You can modify these commands with the below optional arguments\n",
309+
"\n",
310+
"| Argument | Description | Default |\n",
311+
"|----------------|-------------|---------|\n",
312+
"| `-u --url` | The full Redis URL to connec to | `redis://localhost:6379` |\n",
313+
"| `--host` | Redis host to connect to | `localhost` |\n",
314+
"| `-p --port` | Redis port to connect to. Must be an integer | `6379` |\n",
315+
"| `--user` | Redis username, if one is required | `default` |\n",
316+
"| `--ssl` | Boolean flag indicating if ssl is required. If set the Redis base url changes to `rediss://` | None |\n",
317+
"| `-a --password`| Redis password, if one is required| `\"\"` |"
318+
]
319+
},
320+
{
321+
"cell_type": "markdown",
322+
"metadata": {},
323+
"source": [
324+
"### Choosing your Redis instance\n",
325+
"By default rvl first checks if you have `REDIS_URL` environment variable defined and tries to connect to that. If not, it then falls back to `localhost:6379`, unless you pass the `--host` or `--port` arguments"
326+
]
327+
},
274328
{
275329
"cell_type": "code",
276-
"execution_count": 11,
330+
"execution_count": 41,
277331
"metadata": {},
278332
"outputs": [
279333
{
280334
"name": "stdout",
281335
"output_type": "stream",
282336
"text": [
283-
"\u001b[32m22:33:45\u001b[0m \u001b[34m[RedisVL]\u001b[0m \u001b[1;30mINFO\u001b[0m Index deleted successfully\n"
337+
"\u001b[32m18:13:36\u001b[0m \u001b[34m[RedisVL]\u001b[0m \u001b[1;30mINFO\u001b[0m Using Redis address from environment variable, REDIS_URL\n",
338+
"\u001b[32m18:13:36\u001b[0m \u001b[34m[RedisVL]\u001b[0m \u001b[1;30mINFO\u001b[0m Indices:\n",
339+
"\u001b[32m18:13:36\u001b[0m \u001b[34m[RedisVL]\u001b[0m \u001b[1;30mINFO\u001b[0m 1. vectorizers\n"
284340
]
285341
}
286342
],
343+
"source": [
344+
"# specify your Redis instance to connect to\n",
345+
"!rvl index listall --host localhost --port 6379"
346+
]
347+
},
348+
{
349+
"cell_type": "markdown",
350+
"metadata": {},
351+
"source": [
352+
"### Using SSL encription\n",
353+
"If your Redis instance is configured to use SSL encription then set the `--ssl` flag.\n",
354+
"You can similarly specify the username and password to construct the full Redis URL"
355+
]
356+
},
357+
{
358+
"cell_type": "code",
359+
"execution_count": null,
360+
"metadata": {},
361+
"outputs": [],
362+
"source": [
363+
"# connect to rediss://jane_doe:password123@localhost:6379\n",
364+
"!rvl index listall --user jane_doe -a password123 --ssl"
365+
]
366+
},
367+
{
368+
"cell_type": "code",
369+
"execution_count": null,
370+
"metadata": {},
371+
"outputs": [],
287372
"source": [
288373
"!rvl index destroy -i vectorizers"
289374
]
290375
}
291376
],
292377
"metadata": {
293378
"kernelspec": {
294-
"display_name": "rvldev",
379+
"display_name": "redisvl-dev",
295380
"language": "python",
296381
"name": "python3"
297382
},
@@ -305,7 +390,7 @@
305390
"name": "python",
306391
"nbconvert_exporter": "python",
307392
"pygments_lexer": "ipython3",
308-
"version": "3.11.10"
393+
"version": "3.12.2"
309394
}
310395
},
311396
"nbformat": 4,

0 commit comments

Comments
 (0)