Find answers from the community

Updated last year

How can I delete the documents from the vector store index? I used 'index.delete_ref_doc()

At a glance
@kapa.ai How can I delete the documents from the vector store index? I used 'index.delete_ref_doc()', but didn't remove anything.
k
2 comments
Please stand by @MrMJ as I search the knowledge base. I normally take about 20 seconds or so. :wave:
----------------------
To delete documents from the vector store index, you can use the delete method provided by the vector store instance. The delete method requires the document ID as an argument. Here is an example of how you can use it:

Plain Text
document_id = documents[0].doc_id
vector_store.delete(document_id)


After deleting, you can check the number of documents remaining in the index. For example, if you are using Redis as your vector store, you can do it like this:

Plain Text
redis_client = vector_store.client
print("Number of documents", len(redis_client.keys()))


If you want to delete the entire index, you can use the delete_index method:

Plain Text
vector_store.delete_index()


Please note that the delete_ref_doc method you mentioned is not found in the provided extracts. It's possible that you might be using a different method or there might be a typo in your code.

Sources:
  • RedisIndexDemo.ipynb ()
  • TairIndexDemo.ipynb ()
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Add a reply
Sign up and join the conversation on Discord