|
513 | 513 | }, |
514 | 514 | { |
515 | 515 | "cell_type": "code", |
516 | | - "execution_count": 32, |
| 516 | + "execution_count": 45, |
517 | 517 | "metadata": {}, |
518 | 518 | "outputs": [ |
519 | 519 | { |
|
526 | 526 | } |
527 | 527 | ], |
528 | 528 | "source": [ |
529 | | - "import warnings\n", |
530 | 529 | "from redisvl.utils.vectorize import HFTextVectorizer\n", |
531 | 530 | "\n", |
532 | | - "warnings.filterwarnings(\"ignore\", category=FutureWarning, message=r\".*clean_up_tokenization_spaces.*\")\n", |
533 | | - "\n", |
534 | 531 | "emb_model = HFTextVectorizer()\n", |
535 | 532 | "\n", |
536 | 533 | "bike_data = [\n", |
|
573 | 570 | " {\n", |
574 | 571 | " \"name\": \"brand\",\n", |
575 | 572 | " \"type\": \"tag\",\n", |
576 | | - " \"path\": \"$.metadata.brand\" # note the '$'\n", |
| 573 | + " \"path\": \"$.metadata.brand\"\n", |
577 | 574 | " },\n", |
578 | 575 | " {\n", |
579 | 576 | " \"name\": \"price\",\n", |
580 | 577 | " \"type\": \"numeric\",\n", |
581 | | - " \"path\": \"$.metadata.price\" # note the '$'\n", |
| 578 | + " \"path\": \"$.metadata.price\"\n", |
582 | 579 | " },\n", |
583 | 580 | " {\n", |
584 | 581 | " \"name\": \"bike_embedding\",\n", |
|
597 | 594 | }, |
598 | 595 | { |
599 | 596 | "cell_type": "code", |
600 | | - "execution_count": 39, |
| 597 | + "execution_count": 46, |
601 | 598 | "metadata": {}, |
602 | 599 | "outputs": [], |
603 | 600 | "source": [ |
|
613 | 610 | }, |
614 | 611 | { |
615 | 612 | "cell_type": "code", |
616 | | - "execution_count": 40, |
| 613 | + "execution_count": 47, |
617 | 614 | "metadata": {}, |
618 | 615 | "outputs": [ |
619 | 616 | { |
620 | 617 | "data": { |
621 | 618 | "text/plain": [ |
622 | | - "['bike-json:6c32bfb9d5114e23866d564af694a15b',\n", |
623 | | - " 'bike-json:a22a2757f0f043f4a0abdd4ad5322989']" |
| 619 | + "['bike-json:de92cb9955434575b20f4e87a30b03d5',\n", |
| 620 | + " 'bike-json:054ab3718b984532b924946fa5ce00c6']" |
624 | 621 | ] |
625 | 622 | }, |
626 | | - "execution_count": 40, |
| 623 | + "execution_count": 47, |
627 | 624 | "metadata": {}, |
628 | 625 | "output_type": "execute_result" |
629 | 626 | } |
|
634 | 631 | }, |
635 | 632 | { |
636 | 633 | "cell_type": "code", |
637 | | - "execution_count": 43, |
| 634 | + "execution_count": 48, |
638 | 635 | "metadata": {}, |
639 | 636 | "outputs": [], |
640 | 637 | "source": [ |
|
647 | 644 | " return_fields=[\n", |
648 | 645 | " \"brand\",\n", |
649 | 646 | " \"name\",\n", |
| 647 | + " \"$.metadata.type\"\n", |
650 | 648 | " ]\n", |
651 | 649 | " )\n", |
652 | 650 | "\n", |
653 | 651 | "\n", |
654 | 652 | "results = bike_index.query(v)" |
655 | 653 | ] |
656 | 654 | }, |
| 655 | + { |
| 656 | + "cell_type": "markdown", |
| 657 | + "metadata": {}, |
| 658 | + "source": [ |
| 659 | + "**Note:** As shown in the example if you want to retrieve a field from json object that was not indexed you will also need to supply the full path as with `$.metadata.type`." |
| 660 | + ] |
| 661 | + }, |
657 | 662 | { |
658 | 663 | "cell_type": "code", |
659 | | - "execution_count": 42, |
| 664 | + "execution_count": 49, |
660 | 665 | "metadata": {}, |
661 | 666 | "outputs": [ |
662 | 667 | { |
663 | 668 | "data": { |
664 | 669 | "text/plain": [ |
665 | | - "[{'id': 'bike-json:a22a2757f0f043f4a0abdd4ad5322989',\n", |
| 670 | + "[{'id': 'bike-json:054ab3718b984532b924946fa5ce00c6',\n", |
666 | 671 | " 'vector_distance': '0.519989073277',\n", |
667 | | - " 'brand': 'Trek'},\n", |
668 | | - " {'id': 'bike-json:6c32bfb9d5114e23866d564af694a15b',\n", |
| 672 | + " 'brand': 'Trek',\n", |
| 673 | + " '$.metadata.type': 'Enduro bikes'},\n", |
| 674 | + " {'id': 'bike-json:de92cb9955434575b20f4e87a30b03d5',\n", |
669 | 675 | " 'vector_distance': '0.657624483109',\n", |
670 | | - " 'brand': 'Specialized'}]" |
| 676 | + " 'brand': 'Specialized',\n", |
| 677 | + " '$.metadata.type': 'Enduro bikes'}]" |
671 | 678 | ] |
672 | 679 | }, |
673 | | - "execution_count": 42, |
| 680 | + "execution_count": 49, |
674 | 681 | "metadata": {}, |
675 | 682 | "output_type": "execute_result" |
676 | 683 | } |
|
0 commit comments