@@ -21,7 +21,7 @@ def docs_to_kg_flow(flow_builder: cocoindex.FlowBuilder, data_scope: cocoindex.D
2121
2222 conn_spec = cocoindex .add_auth_entry (
2323 "Neo4jConnection" ,
24- cocoindex .storages .Neo4jConnectionSpec (
24+ cocoindex .storages .Neo4jConnection (
2525 uri = "bolt://localhost:7687" ,
2626 user = "neo4j" ,
2727 password = "cocoindex" ,
@@ -70,38 +70,40 @@ def docs_to_kg_flow(flow_builder: cocoindex.FlowBuilder, data_scope: cocoindex.D
7070
7171 relationships .export (
7272 "relationships" ,
73- cocoindex .storages .Neo4jRelationship (
73+ cocoindex .storages .Neo4j (
7474 connection = conn_spec ,
75- rel_type = "RELATIONSHIP" ,
76- source = cocoindex .storages .Neo4jRelationshipEndSpec (
77- label = "Entity" ,
78- fields = [
79- cocoindex .storages .Neo4jFieldMapping (
80- field_name = "subject" , node_field_name = "value" ),
81- cocoindex .storages .Neo4jFieldMapping (
82- field_name = "subject_embedding" , node_field_name = "embedding" ),
83- ]
84- ),
85- target = cocoindex .storages .Neo4jRelationshipEndSpec (
86- label = "Entity" ,
87- fields = [
88- cocoindex .storages .Neo4jFieldMapping (
89- field_name = "object" , node_field_name = "value" ),
90- cocoindex .storages .Neo4jFieldMapping (
91- field_name = "object_embedding" , node_field_name = "embedding" ),
92- ]
93- ),
94- nodes = {
95- "Entity" : cocoindex .storages .Neo4jRelationshipNodeSpec (
96- primary_key_fields = ["value" ],
97- vector_indexes = [
98- cocoindex .VectorIndexDef (
99- field_name = "embedding" ,
100- metric = cocoindex .VectorSimilarityMetric .COSINE_SIMILARITY ,
101- ),
102- ],
75+ mapping = cocoindex .storages .Neo4jRelationship (
76+ rel_type = "RELATIONSHIP" ,
77+ source = cocoindex .storages .Neo4jRelationshipEnd (
78+ label = "Entity" ,
79+ fields = [
80+ cocoindex .storages .Neo4jFieldMapping (
81+ field_name = "subject" , node_field_name = "value" ),
82+ cocoindex .storages .Neo4jFieldMapping (
83+ field_name = "subject_embedding" , node_field_name = "embedding" ),
84+ ]
10385 ),
104- },
86+ target = cocoindex .storages .Neo4jRelationshipEnd (
87+ label = "Entity" ,
88+ fields = [
89+ cocoindex .storages .Neo4jFieldMapping (
90+ field_name = "object" , node_field_name = "value" ),
91+ cocoindex .storages .Neo4jFieldMapping (
92+ field_name = "object_embedding" , node_field_name = "embedding" ),
93+ ]
94+ ),
95+ nodes = {
96+ "Entity" : cocoindex .storages .Neo4jRelationshipNode (
97+ primary_key_fields = ["value" ],
98+ vector_indexes = [
99+ cocoindex .VectorIndexDef (
100+ field_name = "embedding" ,
101+ metric = cocoindex .VectorSimilarityMetric .COSINE_SIMILARITY ,
102+ ),
103+ ],
104+ ),
105+ },
106+ ),
105107 ),
106108 primary_key_fields = ["id" ],
107109 )
0 commit comments