Assuming you stored the original documents somewhere (like in a docstore)
node = retriever.retrieve("query")[0]
doc = docstore.get_document(node.ref_doc_id)
If you aren't using a docstore or didn't store the original document, you will have to use the relationships to pull all the nodes back together. This would probably be a recursive function but I'm too lazy to figure out the specifics lol
But something generally like this
all_nodes = []
cur_node = retriever.retrieve("query")[0]
all_nodes.append(cur_node)
if cur_node.prev_node:
prev_node = vector_store.get_nodes(node_ids=[cur_node.prev_node.node_id])
if cur_node.next_node:
next_node = vector_store.get_nodes(node_ids[cur_node.nexxt_node.node_id])