@@ -92,13 +92,31 @@ def docs_to_kg_flow(flow_builder: cocoindex.FlowBuilder, data_scope: cocoindex.D
9292 id = cocoindex .GeneratedField .UUID , entity = relationship ["object" ],
9393 filename = doc ["filename" ], location = chunk ["location" ],
9494 )
95+
9596 document_node .export (
9697 "document_node" ,
9798 cocoindex .storages .Neo4j (
9899 connection = conn_spec ,
99100 mapping = cocoindex .storages .NodeMapping (label = "Document" )),
100101 primary_key_fields = ["filename" ],
101102 )
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+ )
102120 entity_relationship .export (
103121 "entity_relationship" ,
104122 cocoindex .storages .Neo4j (
@@ -123,17 +141,6 @@ def docs_to_kg_flow(flow_builder: cocoindex.FlowBuilder, data_scope: cocoindex.D
123141 source = "object_embedding" , target = "embedding" ),
124142 ]
125143 ),
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- },
137144 ),
138145 ),
139146 primary_key_fields = ["id" ],
0 commit comments