File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed
learn/experimental/merge-namespaces Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change 52
52
" index_name = \" namespace-test\" # replace with the correct index name\n " ,
53
53
" index = pc.Index(index_name)"
54
54
]
55
+ },
56
+ {
57
+ "cell_type" : " code" ,
58
+ "execution_count" : null ,
59
+ "metadata" : {},
60
+ "outputs" : [],
61
+ "source" : [
62
+ " import random\n " ,
63
+ " \n " ,
64
+ " dimension = index.describe_index_stats()['dimension']\n " ,
65
+ " # Function to fetch all vectors from a namespace\n " ,
66
+ " def fetch_all_vectors(namespace):\n " ,
67
+ " count = index.describe_index_stats()['namespaces'][namespace]['vector_count']\n " ,
68
+ " random_vecs = [random.random() for _ in range(dimension)]\n " ,
69
+ " response = index.query(\n " ,
70
+ " namespace=namespace,\n " ,
71
+ " vector=random_vecs,\n " ,
72
+ " top_k=count,\n " ,
73
+ " include_values=True\n " ,
74
+ " )\n " ,
75
+ " return response['matches']\n " ,
76
+ " \n " ,
77
+ " # Fetch vectors from ns1 and ns2\n " ,
78
+ " vectors_ns1 = fetch_all_vectors(\" ns1\" )\n " ,
79
+ " vectors_ns2 = fetch_all_vectors(\" ns2\" )"
80
+ ]
55
81
}
56
82
],
57
83
"metadata" : {
You can’t perform that action at this time.
0 commit comments