Find answers from the community

Updated 3 months ago

Hello, @Logan M , how to delete document

Hello, , how to delete document knowledge from index in llamaindex python?
My current code
storage_context = StorageContext.from_defaults(persist_dir="./gptdb/"+data['email'])
index = load_index_from_storage(storage_context,service_context=service_context)
index.delete_ref_doc(data["doc_id"], delete_from_docstore=True)
storage_context.persist(persist_dir="./gptdb/"+data['email'])

But, it doesn't delete document knowledge
o
W
8 comments
can you check @WhiteFang_Jr as well?
re-create the query_engine instance after persisting the index once and check.
can you give me example code for this?
Plain Text
storage_context = StorageContext.from_defaults(persist_dir="./gptdb/"+data['email'])
index = load_index_from_storage(storage_context,service_context=service_context)
index.delete_ref_doc(data["doc_id"], delete_from_docstore=True)
storage_context.persist(persist_dir="./gptdb/"+data['email'])
query_engine = index.as_query_engine(previous_entries_here...) # Creating query_engine again after deleting items from the index
query_engine = index.as_query_engine(previous_entries_here...)
Although I don't need to query after deleting, should I do that?
How are you checking your doc is not deleted?
I am checking json vector store, btw could confirm that it didn't delete
Hello, @Logan M , Hope you are doing well. could you please advice when you are online?
Add a reply
Sign up and join the conversation on Discord