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