Find answers from the community

Updated 6 months ago

How to reuse already created indexes

How to reuse already created indexes properly?

I have a function

Plain Text
def index_profiles_data(
    pinecone_index,
    nodes: Optional[List[BaseNode]] = None,
    namespace: str = "test_namespace",

) -> VectorStoreIndex:
    """Indexes the profiles data using a VectorStore.
    Args:
        nodes: List[BaseNode]: List of nodes to index.
        pinecone_index: Pinecone: Pinecone index object.
        namespace: str: Namespace for the Pinecone vector store.
    Returns:
        VectorStoreIndex: Index that can be used for retrieval and querying.
    """
    # Setup Pinecone Vector Store
    vector_store = PineconeVectorStore(
        pinecone_index=pinecone_index, namespace=namespace
    )
    if nodes:
        storage_context = StorageContext.from_defaults(
            vector_store=vector_store
        )
        # Create Vector Store Index
        vector_store_index = VectorStoreIndex(nodes=nodes, storage_context=storage_context)

    else:
        vector_store_index = VectorStoreIndex.from_vector_store(
            vector_store=vector_store
        )
    logging.info("Vector store index created and ready for use.")
    return vector_store_index


When I pass in the nodes, it works well and I am able to retrieve things. When i dont pass in nodes and use from vector_store it to return anything. How can I resolve this?
L
N
2 comments
from_vector_store() is the correct method to use if your vector store is pointing to an existing collection.

It works for me on pinecone πŸ€”
Thanks. Will check what I am doing wrong. Good to know that I am approaching it correctly.
Add a reply
Sign up and join the conversation on Discord