How to reuse already created indexes properly?
I have a function
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?