From 769999517dd65cf66a55342d33ec2b526cb117cf Mon Sep 17 00:00:00 2001 From: dishaprakash <57954147+dishaprakash@users.noreply.github.com> Date: Mon, 16 Dec 2024 23:30:58 +0000 Subject: [PATCH] chore(docs): Add multiple namespaces option in migration guide. (#290) * fix: Add multiple namespaces option in migration guide. * Changed layout * Changed layout * Minor fix * Minor fix * Minor fix --------- Co-authored-by: Averi Kitsch --- .../migrate_vectorstore_to_alloydb.md | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/samples/migrations/migrate_vectorstore_to_alloydb.md b/samples/migrations/migrate_vectorstore_to_alloydb.md index fdaca94f..d020b3db 100644 --- a/samples/migrations/migrate_vectorstore_to_alloydb.md +++ b/samples/migrations/migrate_vectorstore_to_alloydb.md @@ -80,6 +80,35 @@ The process of getting data from vector stores varies depending on the specific return ids, content, embeddings, metadatas ``` + 4. (Optional) Get all data from index from a specific namespace + + ```python + def get_all_ids(namespace): + results = index.list_paginated(prefix="", namespace=namespace) + ids = [v.id for v in results.vectors] + while results.pagination is not None: + pagination_token = results.pagination.next + results = index.list_paginated(prefix="", pagination_token=pagination_token, namespace=namespace) + ids.extend([v.id for v in results.vectors]) + return ids + + def get_all_data(namespace): + all_data = index.fetch(ids=get_all_ids(index), namespace=namespace) + ids = [] + embeddings = [] + content = [] + metadatas = [] + for doc in all_data["vectors"].values(): + ids.append(doc["id"]) + embeddings.append(doc["values"]) + content.append(doc["metadata"]["text"]) + metadata = doc["metadata"] + del metadata["text"] + metadatas.append(metadata) + return ids, content, embeddings, metadatas + ``` + To know more about working with multiple namespaces, see [docs](https://docs.pinecone.io/guides/indexes/use-namespaces). + #### Weaviate 1. Install any prerequisites using the [docs](https://weaviate.io/developers/weaviate/client-libraries/python#installation).