run-llama/llama_index · error · NotImplementedError

Ref doc info not implemented for PropertyGraphIndex. All ins

Error message

Ref doc info not implemented for PropertyGraphIndex. All inserts are already upserts.

What it means

PropertyGraphIndex.ref_doc_info deliberately raises NotImplementedError: because every insert into a property graph is an upsert (nodes are keyed by ID, not tracked per source document), the index cannot reconstruct a mapping of ingested documents to their nodes.

Source

Thrown at llama-index-core/llama_index/core/indices/property_graph/base.py:407

                        **kwargs,
                    )
                )

        use_async_val = kwargs.pop("use_async", self._use_async)
        return PGRetriever(sub_retrievers, use_async=use_async_val, **kwargs)

    def _delete_node(self, node_id: str, **delete_kwargs: Any) -> None:
        """Delete a node."""
        self.property_graph_store.delete(ids=[node_id])

    def _insert(self, nodes: Sequence[BaseNode], **insert_kwargs: Any) -> None:
        """Index-specific logic for inserting nodes to the index struct."""
        self._insert_nodes(nodes)

    @property
    def ref_doc_info(self) -> Dict[str, RefDocInfo]:
        """Retrieve a dict mapping of ingested documents and their nodes+metadata."""
        raise NotImplementedError(
            "Ref doc info not implemented for PropertyGraphIndex. "
            "All inserts are already upserts."
        )

View on GitHub (pinned to afd0fef371)

Solutions

  1. Query the graph store directly, e.g. property_graph_store.get(properties={'ref_doc_id': doc_id}) to find nodes derived from a document
  2. Maintain your own doc-id -> node-id mapping at insert time
  3. Switch to VectorStoreIndex if per-document node tracking is a hard requirement
  4. Guard access with isinstance(index, PropertyGraphIndex) checks in shared code paths

Example fix

# before
info = index.ref_doc_info  # raises on PropertyGraphIndex

# after
nodes = index.property_graph_store.get(properties={"ref_doc_id": doc_id})
Defensive patterns

Strategy: type-guard

Validate before calling

from llama_index.core.indices.property_graph import PropertyGraphIndex
if isinstance(index, PropertyGraphIndex):
    nodes = index.property_graph_store.get(properties={'ref_doc_id': doc_id})
else:
    info = index.ref_doc_info

Type guard

def safe_ref_doc_info(index) -> dict:
    from llama_index.core.indices.property_graph import PropertyGraphIndex
    if isinstance(index, PropertyGraphIndex):
        return {}  # not supported; upserts only
    return index.ref_doc_info

Try / catch

try:
    info = index.ref_doc_info
except NotImplementedError:
    info = {}  # property graph indexes: track docs yourself

Prevention

When it happens

Trigger: Accessing index.ref_doc_info on a PropertyGraphIndex, or calling APIs that internally consult ref_doc_info (e.g. some delete/document-tracking utilities, index.ref_doc_info property access).

Common situations: Porting code written for VectorStoreIndex/SummaryIndex that used ref_doc_info for document management; building document-deletion workflows that assume per-doc node tracking.

Related errors


AI-assisted analysis of run-llama/llama_index@afd0fef371 (2026-08-15). Data as JSON: /api/errors/ef1c4401a3847367. Report an issue: GitHub.