Skip to content

Commit 5aca45b

Browse files
committed
add example for accessing in return statement
1 parent e75f1b8 commit 5aca45b

File tree

1 file changed

+25
-18
lines changed

1 file changed

+25
-18
lines changed

docs/user_guide/05_hash_vs_json.ipynb

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,7 @@
513513
},
514514
{
515515
"cell_type": "code",
516-
"execution_count": 32,
516+
"execution_count": 45,
517517
"metadata": {},
518518
"outputs": [
519519
{
@@ -526,11 +526,8 @@
526526
}
527527
],
528528
"source": [
529-
"import warnings\n",
530529
"from redisvl.utils.vectorize import HFTextVectorizer\n",
531530
"\n",
532-
"warnings.filterwarnings(\"ignore\", category=FutureWarning, message=r\".*clean_up_tokenization_spaces.*\")\n",
533-
"\n",
534531
"emb_model = HFTextVectorizer()\n",
535532
"\n",
536533
"bike_data = [\n",
@@ -573,12 +570,12 @@
573570
" {\n",
574571
" \"name\": \"brand\",\n",
575572
" \"type\": \"tag\",\n",
576-
" \"path\": \"$.metadata.brand\" # note the '$'\n",
573+
" \"path\": \"$.metadata.brand\"\n",
577574
" },\n",
578575
" {\n",
579576
" \"name\": \"price\",\n",
580577
" \"type\": \"numeric\",\n",
581-
" \"path\": \"$.metadata.price\" # note the '$'\n",
578+
" \"path\": \"$.metadata.price\"\n",
582579
" },\n",
583580
" {\n",
584581
" \"name\": \"bike_embedding\",\n",
@@ -597,7 +594,7 @@
597594
},
598595
{
599596
"cell_type": "code",
600-
"execution_count": 39,
597+
"execution_count": 46,
601598
"metadata": {},
602599
"outputs": [],
603600
"source": [
@@ -613,17 +610,17 @@
613610
},
614611
{
615612
"cell_type": "code",
616-
"execution_count": 40,
613+
"execution_count": 47,
617614
"metadata": {},
618615
"outputs": [
619616
{
620617
"data": {
621618
"text/plain": [
622-
"['bike-json:6c32bfb9d5114e23866d564af694a15b',\n",
623-
" 'bike-json:a22a2757f0f043f4a0abdd4ad5322989']"
619+
"['bike-json:de92cb9955434575b20f4e87a30b03d5',\n",
620+
" 'bike-json:054ab3718b984532b924946fa5ce00c6']"
624621
]
625622
},
626-
"execution_count": 40,
623+
"execution_count": 47,
627624
"metadata": {},
628625
"output_type": "execute_result"
629626
}
@@ -634,7 +631,7 @@
634631
},
635632
{
636633
"cell_type": "code",
637-
"execution_count": 43,
634+
"execution_count": 48,
638635
"metadata": {},
639636
"outputs": [],
640637
"source": [
@@ -647,30 +644,40 @@
647644
" return_fields=[\n",
648645
" \"brand\",\n",
649646
" \"name\",\n",
647+
" \"$.metadata.type\"\n",
650648
" ]\n",
651649
" )\n",
652650
"\n",
653651
"\n",
654652
"results = bike_index.query(v)"
655653
]
656654
},
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+
},
657662
{
658663
"cell_type": "code",
659-
"execution_count": 42,
664+
"execution_count": 49,
660665
"metadata": {},
661666
"outputs": [
662667
{
663668
"data": {
664669
"text/plain": [
665-
"[{'id': 'bike-json:a22a2757f0f043f4a0abdd4ad5322989',\n",
670+
"[{'id': 'bike-json:054ab3718b984532b924946fa5ce00c6',\n",
666671
" '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",
669675
" 'vector_distance': '0.657624483109',\n",
670-
" 'brand': 'Specialized'}]"
676+
" 'brand': 'Specialized',\n",
677+
" '$.metadata.type': 'Enduro bikes'}]"
671678
]
672679
},
673-
"execution_count": 42,
680+
"execution_count": 49,
674681
"metadata": {},
675682
"output_type": "execute_result"
676683
}

0 commit comments

Comments
 (0)