Putting check on recreation of Vector indexes of the data in Pinecone

I have stored embedding of the data in the vector database but why it is generating embedding again and again and storing that into vector database. Is there any way to put a check on this if once vector indexes are generated then it should not be created again instead creating it should throw message that indexes are already created. Can anybody please help regarding this if already faced such type of issue.
Thanks in advance.


This is the code I am using.

Hi @shivam22123, and welcome to the Pinecone forums!

Thank you for your question.

It looks like you’re using LangChain’s Pinecone integration to call

PineconeVectorStore.from_documents - which is a method that’s intended to create a vector database from the documents you provide, including doing all the setup:

  • Creating the Pinecone index if necessary
  • Converting all documents to embeddings
  • Upserting the documents with metadata

If, instead, you’re looking to connect to an existing Pinecone vector database using LangChain’s library, you should take a look at the PineconeVectorStore class which allows you to attach to an existing index:

embeddings =  OpenAIEmbeddings()
vectorstore = PineconeVectorStore(embedding=embeddings, index_name=index_name)

vectorstore.similarity_search(query)

You can also view our up-to-date official guide on using LangChain here.

Hope this helps!