|
209 | 209 | }, |
210 | 210 | { |
211 | 211 | "cell_type": "code", |
212 | | - "execution_count": null, |
| 212 | + "execution_count": 4, |
213 | 213 | "metadata": {}, |
214 | | - "outputs": [], |
| 214 | + "outputs": [ |
| 215 | + { |
| 216 | + "data": { |
| 217 | + "text/plain": [ |
| 218 | + "<redisvl.index.index.SearchIndex at 0x10faca900>" |
| 219 | + ] |
| 220 | + }, |
| 221 | + "execution_count": 4, |
| 222 | + "metadata": {}, |
| 223 | + "output_type": "execute_result" |
| 224 | + } |
| 225 | + ], |
215 | 226 | "source": [ |
216 | 227 | "from redis import Redis\n", |
217 | 228 | "\n", |
|
238 | 249 | { |
239 | 250 | "data": { |
240 | 251 | "text/plain": [ |
241 | | - "<redisvl.index.index.SearchIndex at 0x7f8670a51190>" |
| 252 | + "<redisvl.index.index.SearchIndex at 0x10faca900>" |
242 | 253 | ] |
243 | 254 | }, |
244 | 255 | "execution_count": 5, |
|
293 | 304 | "name": "stdout", |
294 | 305 | "output_type": "stream", |
295 | 306 | "text": [ |
296 | | - "\u001b[32m11:53:23\u001b[0m \u001b[34m[RedisVL]\u001b[0m \u001b[1;30mINFO\u001b[0m Indices:\n", |
297 | | - "\u001b[32m11:53:23\u001b[0m \u001b[34m[RedisVL]\u001b[0m \u001b[1;30mINFO\u001b[0m 1. user_simple\n" |
| 307 | + "\u001b[32m11:50:15\u001b[0m \u001b[34m[RedisVL]\u001b[0m \u001b[1;30mINFO\u001b[0m Indices:\n", |
| 308 | + "\u001b[32m11:50:15\u001b[0m \u001b[34m[RedisVL]\u001b[0m \u001b[1;30mINFO\u001b[0m 1. user_simple\n" |
298 | 309 | ] |
299 | 310 | } |
300 | 311 | ], |
|
320 | 331 | "│ user_simple │ HASH │ ['user_simple_docs'] │ [] │ 0 │\n", |
321 | 332 | "╰──────────────┴────────────────┴──────────────────────┴─────────────────┴────────────╯\n", |
322 | 333 | "Index Fields:\n", |
323 | | - "╭────────────────┬────────────────┬─────────┬────────────────┬────────────────╮\n", |
324 | | - "│ Name │ Attribute │ Type │ Field Option │ Option Value │\n", |
325 | | - "├────────────────┼────────────────┼─────────┼────────────────┼────────────────┤\n", |
326 | | - "│ user │ user │ TAG │ SEPARATOR │ , │\n", |
327 | | - "│ credit_score │ credit_score │ TAG │ SEPARATOR │ , │\n", |
328 | | - "│ job │ job │ TEXT │ WEIGHT │ 1 │\n", |
329 | | - "│ age │ age │ NUMERIC │ │ │\n", |
330 | | - "│ user_embedding │ user_embedding │ VECTOR │ │ │\n", |
331 | | - "╰────────────────┴────────────────┴─────────┴────────────────┴────────────────╯\n" |
| 334 | + "╭────────────────┬────────────────┬─────────┬────────────────┬────────────────┬────────────────┬────────────────┬────────────────┬────────────────┬─────────────────┬────────────────╮\n", |
| 335 | + "│ Name │ Attribute │ Type │ Field Option │ Option Value │ Field Option │ Option Value │ Field Option │ Option Value │ Field Option │ Option Value │\n", |
| 336 | + "├────────────────┼────────────────┼─────────┼────────────────┼────────────────┼────────────────┼────────────────┼────────────────┼────────────────┼─────────────────┼────────────────┤\n", |
| 337 | + "│ user │ user │ TAG │ SEPARATOR │ , │ │ │ │ │ │ │\n", |
| 338 | + "│ credit_score │ credit_score │ TAG │ SEPARATOR │ , │ │ │ │ │ │ │\n", |
| 339 | + "│ job │ job │ TEXT │ WEIGHT │ 1 │ │ │ │ │ │ │\n", |
| 340 | + "│ age │ age │ NUMERIC │ │ │ │ │ │ │ │ │\n", |
| 341 | + "│ user_embedding │ user_embedding │ VECTOR │ algorithm │ FLAT │ data_type │ FLOAT32 │ dim │ 3 │ distance_metric │ COSINE │\n", |
| 342 | + "╰────────────────┴────────────────┴─────────┴────────────────┴────────────────┴────────────────┴────────────────┴────────────────┴────────────────┴─────────────────┴────────────────╯\n" |
332 | 343 | ] |
333 | 344 | } |
334 | 345 | ], |
|
354 | 365 | "name": "stdout", |
355 | 366 | "output_type": "stream", |
356 | 367 | "text": [ |
357 | | - "['user_simple_docs:d424b73c516442f7919cc11ed3bb1882', 'user_simple_docs:6da16f88342048e79b3500bec5448805', 'user_simple_docs:ef5a590ef85e4d4888fd8ebe79ae1e8c']\n" |
| 368 | + "['user_simple_docs:01JM2NWFWNH0BNA640MT5DS8BD', 'user_simple_docs:01JM2NWFWNF4S2V4E4HYG25CVA', 'user_simple_docs:01JM2NWFWNBFXJJ4PV9F4KMJSE']\n" |
358 | 369 | ] |
359 | 370 | } |
360 | 371 | ], |
|
388 | 399 | "name": "stdout", |
389 | 400 | "output_type": "stream", |
390 | 401 | "text": [ |
391 | | - "['user_simple_docs:9806a362604f4700b17513cc94fcf10d']\n" |
| 402 | + "['user_simple_docs:01JM2NWJGYMJ0QTR5YB4MB0BX9']\n" |
392 | 403 | ] |
393 | 404 | } |
394 | 405 | ], |
|
476 | 487 | }, |
477 | 488 | { |
478 | 489 | "cell_type": "code", |
479 | | - "execution_count": null, |
| 490 | + "execution_count": 13, |
480 | 491 | "metadata": {}, |
481 | | - "outputs": [], |
| 492 | + "outputs": [ |
| 493 | + { |
| 494 | + "data": { |
| 495 | + "text/plain": [ |
| 496 | + "{'index': {'name': 'user_simple', 'prefix': 'user_simple_docs'},\n", |
| 497 | + " 'fields': [{'name': 'user', 'type': 'tag'},\n", |
| 498 | + " {'name': 'credit_score', 'type': 'tag'},\n", |
| 499 | + " {'name': 'job', 'type': 'text'},\n", |
| 500 | + " {'name': 'age', 'type': 'numeric'},\n", |
| 501 | + " {'name': 'user_embedding',\n", |
| 502 | + " 'type': 'vector',\n", |
| 503 | + " 'attrs': {'dims': 3,\n", |
| 504 | + " 'distance_metric': 'cosine',\n", |
| 505 | + " 'algorithm': 'flat',\n", |
| 506 | + " 'datatype': 'float32'}}]}" |
| 507 | + ] |
| 508 | + }, |
| 509 | + "execution_count": 13, |
| 510 | + "metadata": {}, |
| 511 | + "output_type": "execute_result" |
| 512 | + } |
| 513 | + ], |
| 514 | + "source": [ |
| 515 | + "schema" |
| 516 | + ] |
| 517 | + }, |
| 518 | + { |
| 519 | + "cell_type": "code", |
| 520 | + "execution_count": 14, |
| 521 | + "metadata": {}, |
| 522 | + "outputs": [ |
| 523 | + { |
| 524 | + "data": { |
| 525 | + "text/plain": [ |
| 526 | + "<redisvl.index.index.AsyncSearchIndex at 0x10facacf0>" |
| 527 | + ] |
| 528 | + }, |
| 529 | + "execution_count": 14, |
| 530 | + "metadata": {}, |
| 531 | + "output_type": "execute_result" |
| 532 | + } |
| 533 | + ], |
482 | 534 | "source": [ |
483 | 535 | "from redisvl.index import AsyncSearchIndex\n", |
484 | 536 | "from redis.asyncio import Redis\n", |
|
491 | 543 | }, |
492 | 544 | { |
493 | 545 | "cell_type": "code", |
494 | | - "execution_count": 14, |
| 546 | + "execution_count": 15, |
495 | 547 | "metadata": {}, |
496 | 548 | "outputs": [ |
497 | 549 | { |
|
532 | 584 | }, |
533 | 585 | { |
534 | 586 | "cell_type": "code", |
535 | | - "execution_count": 15, |
| 587 | + "execution_count": 16, |
536 | 588 | "metadata": {}, |
537 | 589 | "outputs": [], |
538 | 590 | "source": [ |
|
620 | 672 | "│ Stat Key │ Value │\n", |
621 | 673 | "├─────────────────────────────┼─────────────┤\n", |
622 | 674 | "│ num_docs │ 4 │\n", |
623 | | - "│ num_terms │ 0 │\n", |
| 675 | + "│ num_terms │ 4 │\n", |
624 | 676 | "│ max_doc_id │ 4 │\n", |
625 | | - "│ num_records │ 20 │\n", |
| 677 | + "│ num_records │ 22 │\n", |
626 | 678 | "│ percent_indexed │ 1 │\n", |
627 | 679 | "│ hash_indexing_failures │ 0 │\n", |
628 | | - "│ number_of_uses │ 2 │\n", |
629 | | - "│ bytes_per_record_avg │ 1 │\n", |
630 | | - "│ doc_table_size_mb │ 0.00044632 │\n", |
631 | | - "│ inverted_sz_mb │ 1.90735e-05 │\n", |
632 | | - "│ key_table_size_mb │ 0.000138283 │\n", |
633 | | - "│ offset_bits_per_record_avg │ nan │\n", |
634 | | - "│ offset_vectors_sz_mb │ 0 │\n", |
635 | | - "│ offsets_per_term_avg │ 0 │\n", |
636 | | - "│ records_per_doc_avg │ 5 │\n", |
| 680 | + "│ number_of_uses │ 5 │\n", |
| 681 | + "│ bytes_per_record_avg │ 50.9091 │\n", |
| 682 | + "│ doc_table_size_mb │ 0.000423431 │\n", |
| 683 | + "│ inverted_sz_mb │ 0.00106812 │\n", |
| 684 | + "│ key_table_size_mb │ 0.000165939 │\n", |
| 685 | + "│ offset_bits_per_record_avg │ 8 │\n", |
| 686 | + "│ offset_vectors_sz_mb │ 5.72205e-06 │\n", |
| 687 | + "│ offsets_per_term_avg │ 0.272727 │\n", |
| 688 | + "│ records_per_doc_avg │ 5.5 │\n", |
637 | 689 | "│ sortable_values_size_mb │ 0 │\n", |
638 | | - "│ total_indexing_time │ 1.796 │\n", |
639 | | - "│ total_inverted_index_blocks │ 11 │\n", |
640 | | - "│ vector_index_sz_mb │ 0.235603 │\n", |
| 690 | + "│ total_indexing_time │ 0.197 │\n", |
| 691 | + "│ total_inverted_index_blocks │ 12 │\n", |
| 692 | + "│ vector_index_sz_mb │ 0.0201416 │\n", |
641 | 693 | "╰─────────────────────────────┴─────────────╯\n" |
642 | 694 | ] |
643 | 695 | } |
|
657 | 709 | "cell_type": "markdown", |
658 | 710 | "metadata": {}, |
659 | 711 | "source": [ |
660 | | - "Below we will clean up after our work. First, you can optionally flush all data from Redis associated with the index by\n", |
| 712 | + "Below we will clean up after our work. First, you can flush all data from Redis associated with the index by\n", |
661 | 713 | "using the `.clear()` method. This will leave the secondary index in place for future insertions or updates.\n", |
662 | 714 | "\n", |
663 | 715 | "But if you want to clean up everything, including the index, just use `.delete()`\n", |
|
666 | 718 | }, |
667 | 719 | { |
668 | 720 | "cell_type": "code", |
669 | | - "execution_count": null, |
| 721 | + "execution_count": 19, |
670 | 722 | "metadata": {}, |
671 | | - "outputs": [], |
| 723 | + "outputs": [ |
| 724 | + { |
| 725 | + "data": { |
| 726 | + "text/plain": [ |
| 727 | + "4" |
| 728 | + ] |
| 729 | + }, |
| 730 | + "execution_count": 19, |
| 731 | + "metadata": {}, |
| 732 | + "output_type": "execute_result" |
| 733 | + } |
| 734 | + ], |
672 | 735 | "source": [ |
673 | | - "# (optionally) clear all data from Redis associated with the index\n", |
| 736 | + "# Clear all data from Redis associated with the index\n", |
674 | 737 | "await index.clear()" |
675 | 738 | ] |
676 | 739 | }, |
677 | 740 | { |
678 | 741 | "cell_type": "code", |
679 | | - "execution_count": null, |
| 742 | + "execution_count": 20, |
680 | 743 | "metadata": {}, |
681 | | - "outputs": [], |
| 744 | + "outputs": [ |
| 745 | + { |
| 746 | + "data": { |
| 747 | + "text/plain": [ |
| 748 | + "True" |
| 749 | + ] |
| 750 | + }, |
| 751 | + "execution_count": 20, |
| 752 | + "metadata": {}, |
| 753 | + "output_type": "execute_result" |
| 754 | + } |
| 755 | + ], |
682 | 756 | "source": [ |
683 | | - "# but the index is still in place\n", |
| 757 | + "# Butm the index is still in place\n", |
684 | 758 | "await index.exists()" |
685 | 759 | ] |
686 | 760 | }, |
687 | 761 | { |
688 | 762 | "cell_type": "code", |
689 | | - "execution_count": 19, |
| 763 | + "execution_count": 21, |
690 | 764 | "metadata": {}, |
691 | 765 | "outputs": [], |
692 | 766 | "source": [ |
693 | | - "# remove / delete the index in its entirety\n", |
| 767 | + "# Remove / delete the index in its entirety\n", |
694 | 768 | "await index.delete()" |
695 | 769 | ] |
696 | 770 | } |
|
711 | 785 | "name": "python", |
712 | 786 | "nbconvert_exporter": "python", |
713 | 787 | "pygments_lexer": "ipython3", |
714 | | - "version": "3.11.9" |
| 788 | + "version": "3.13.2" |
715 | 789 | }, |
716 | 790 | "orig_nbformat": 4 |
717 | 791 | }, |
|
0 commit comments