@@ -92,13 +92,31 @@ def docs_to_kg_flow(flow_builder: cocoindex.FlowBuilder, data_scope: cocoindex.D
92
92
id = cocoindex .GeneratedField .UUID , entity = relationship ["object" ],
93
93
filename = doc ["filename" ], location = chunk ["location" ],
94
94
)
95
+
95
96
document_node .export (
96
97
"document_node" ,
97
98
cocoindex .storages .Neo4j (
98
99
connection = conn_spec ,
99
100
mapping = cocoindex .storages .NodeMapping (label = "Document" )),
100
101
primary_key_fields = ["filename" ],
101
102
)
103
+ flow_builder .declare (
104
+ cocoindex .storages .Neo4jDeclarations (
105
+ connection = conn_spec ,
106
+ referenced_nodes = [
107
+ cocoindex .storages .ReferencedNode (
108
+ label = "Entity" ,
109
+ primary_key_fields = ["value" ],
110
+ vector_indexes = [
111
+ cocoindex .VectorIndexDef (
112
+ field_name = "embedding" ,
113
+ metric = cocoindex .VectorSimilarityMetric .COSINE_SIMILARITY ,
114
+ ),
115
+ ],
116
+ )
117
+ ]
118
+ )
119
+ )
102
120
entity_relationship .export (
103
121
"entity_relationship" ,
104
122
cocoindex .storages .Neo4j (
@@ -123,17 +141,6 @@ def docs_to_kg_flow(flow_builder: cocoindex.FlowBuilder, data_scope: cocoindex.D
123
141
source = "object_embedding" , target = "embedding" ),
124
142
]
125
143
),
126
- nodes_storage_spec = {
127
- "Entity" : cocoindex .storages .NodeStorageSpec (
128
- primary_key_fields = ["value" ],
129
- vector_indexes = [
130
- cocoindex .VectorIndexDef (
131
- field_name = "embedding" ,
132
- metric = cocoindex .VectorSimilarityMetric .COSINE_SIMILARITY ,
133
- ),
134
- ],
135
- ),
136
- },
137
144
),
138
145
),
139
146
primary_key_fields = ["id" ],
0 commit comments