Find answers from the community

Updated last year

Thanks again for this Logan M I started

Thanks again for this @Logan M. I started investigating Pinecone as a vector store. I'm having trouble finding:
  1. How do you delete documents from an index.
  2. How to add a namespace.
  3. How to add documents under a namespace.
  4. How do you add metadata for filtering for a query.
  5. How to update metadata for a filtering on existing docs.
L
O
10 comments
When you insert documents, each Document has a doc_id. You can eithe record this ID or set it to something else before inserting. Then you can use index.delete(doc_id). This will delete all nodes created from this document

If you need to, you can also check source nodes from a response to get the doc id

response.source_nodes[0].node.ref_doc_id
namespace is configured in the pinecone vector store constructor

PineconeVectorStore(..., namespace="my_namespace")
Updating metdata is not really supported for any index right now -- need to delete and re-add
Thanks again. How does one add a single document to an existing index? Does VectorStoreIndex.from_documents() add to an existing index or is there another function to insert a single document to an existing index? I'm only see tutorials in the context of creating the index from scratch.
index.insert(document)
So, something like this?
Plain Text
index = VectorStoreIndex(
  vector_store=vector_store,
  storage_context=storage_context,
  service_context=service_context,
)
[index.insert(doc) for doc in documents]
uhhh not quite

This will create an empty index, that you are then inserting into
Plain Text
index = VectorStoreIndex(
  [],
  storage_context=storage_context,
  service_context=service_context,
)
[index.insert(doc) for doc in documents]
If you have an existing vector index, you can load it from disk using load_index_from_storage()

If you are using a vector db integration, you can connect back to it by setting up the vector store object to point to the existing index, and then do

Plain Text
index = VectorStoreIndex.from_vector_store(
  vector_store,
  service_context=service_context,
)
Perfect. Thanks
Add a reply
Sign up and join the conversation on Discord