Skip to content

Commit

Permalink
chore(docs): Add multiple namespaces option in migration guide. (#290)
Browse files Browse the repository at this point in the history
* fix: Add multiple namespaces option in migration guide.

* Changed layout

* Changed layout

* Minor fix

* Minor fix

* Minor fix

---------

Co-authored-by: Averi Kitsch <[email protected]>
  • Loading branch information
dishaprakash and averikitsch authored Dec 16, 2024
1 parent ebb64bf commit 7699995
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions samples/migrations/migrate_vectorstore_to_alloydb.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down

0 comments on commit 7699995

Please sign in to comment.