ChunkWriter mirrors chunks into Neo4j after OpenSearch indexing, creating
HAS_CHUNK edges and DERIVED_FROM back-references to the source Elements
(via doc_items propagated from the local chunker).
Graph API: GET /api/documents/{id}/graph returns a cytoscape-shaped
payload with nodes + edges for Document / Element / Page / Chunk.
Hard cap at 200 pages returns HTTP 413 per design §8.4.
Frontend: new Graph tab in Studio results, rendered with Cytoscape.js +
dagre layout (lazy-loaded, ~175 KB gz). Legend, node styling per element
label, directional edges styled per edge type.
README gains a Neo4j section with the schema, three demo Cypher
queries, and env vars. Backend tests skip cleanly when the neo4j python
package is not installed locally.
Refs #186
31 lines
865 B
Python
31 lines
865 B
Python
"""Neo4j storage adapter — graph-native document structure.
|
|
|
|
Provides a thin driver wrapper, idempotent schema bootstrap, and
|
|
walkers between DoclingDocument and the graph model.
|
|
"""
|
|
|
|
from infra.neo4j.chunk_writer import ChunkWriteResult, write_chunks
|
|
from infra.neo4j.driver import Neo4jDriver, close_driver, get_driver
|
|
from infra.neo4j.queries import fetch_graph
|
|
from infra.neo4j.schema import bootstrap_schema
|
|
from infra.neo4j.tree_reader import (
|
|
delete_document,
|
|
document_exists,
|
|
read_document_json,
|
|
)
|
|
from infra.neo4j.tree_writer import TreeWriteResult, write_document
|
|
|
|
__all__ = [
|
|
"ChunkWriteResult",
|
|
"Neo4jDriver",
|
|
"TreeWriteResult",
|
|
"bootstrap_schema",
|
|
"close_driver",
|
|
"delete_document",
|
|
"document_exists",
|
|
"fetch_graph",
|
|
"get_driver",
|
|
"read_document_json",
|
|
"write_chunks",
|
|
"write_document",
|
|
]
|