Skip to content

when a Document is roundtripped through a VectorStore, it is returned as a TextNode #2245

@jeremybmerrill

Description

@jeremybmerrill

@marcusschiesser and I agree in #2232 that, when a Document is roundtripped through a VectorStore, it should be returned as a Document. It is currently returned as a TextNode.

The culprit is metadataDictToNode, which returns only Nodes of type INDEX and TEXT. This function is used in most vector stores to rehydrate a JSON dict representing a node into a Node object. The function should probably be modified to return Document (and perhaps other types of nodes that might be stored in a VectorStore).

Note that nodeToMetadata, the counterpart to metadataDictToNode does appear to properly record the nodeType and _node_type attributes in the metadata dict that is written to Postgres in PGVectorStore: {"doc_id": "None", "nodeType": "Document", "_node_type": "Document", "ref_doc_id": "None", "create_date": "2025-11-28T22:45:33.046Z", "document_id": "None", "_node_content": "{\"id_\":\"5bb16627-f6c0-459c-bb18-71642813ef21\",\"excludedEmbedMetadataKeys\":[],\"excludedLlmMetadataKeys\":[],\"relationships\":{},\"text\":\"\",\"textTemplate\":\"\",\"metadataSeparator\":\"\\n\",\"type\":\"DOCUMENT\",\"hash\":\"+yyksHlikZPxyhP5bhcUU4c04Jy/8FWHIuNN3Ef3V98=\"}"}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions