Find answers from the community

Updated last year

I have indexed many documents in a

I have indexed many documents in a VectorStoreIndex. How can I delete a document from the Index using the documents; I donot have track of what document has what id in Index?
W
s
3 comments
You'll need to check your docstore.json file and see which chunks or part of docs you do not want and note down the doc_ID and then simply
Plain Text
doc_id = "your_doc_id"
index.delete(doc_id)


This will take a lot of time, I would suggest you index fresh with the documents and then when indexing you can set doc ID with the filename, That way when you want to remove you can simply put the file name in delete method.
okay, thanks.
could you guide on how can i put a custom doc_id?
Way 1:
Plain Text
documents = SimpleDirectoryReader("../data/paul_graham").load_data()

for document in documents:
    document.id_ = "your_document_id"


Way 2:
Plain Text
# Add a new document
new_document = Document(text="This isn't in the index yet, but it will be soon!", id_="doc_id_3")
Add a reply
Sign up and join the conversation on Discord