You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/docs/ops/storages.md
+28-18Lines changed: 28 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -48,36 +48,46 @@ You can find an end-to-end example [here](https://github.com/cocoindex-io/cocoin
48
48
49
49
## Neo4j
50
50
51
-
### Setup
52
-
53
51
If you don't have a Postgres database, you can start a Postgres SQL database for cocoindex using our docker compose config:
54
52
55
53
```bash
56
54
docker compose -f <(curl -L https://raw.githubusercontent.com/cocoindex-io/cocoindex/refs/heads/main/dev/neo4j.yaml) up -d
57
55
```
58
56
59
-
### Neo4jRelationship
60
-
61
-
The `Neo4jRelationship` storage exports each row as a relationship to Neo4j Knowledge Graph.
62
-
When you collect rows for `Neo4jRelationship`, fields will be mapped to a relationship and source/target nodes for the relationship:
57
+
:::warning
63
58
64
-
* You can explicitly specify fields mapped to source/target nodes.
65
-
* All remaining fields will be mapped to relationship properties by default.
59
+
The docker compose config above will start a Neo4j Enterprise instance under the [Evaluation License](https://neo4j.com/terms/enterprise_us/),
60
+
with 30 days trial period.
61
+
Please read and agree the license before starting the instance.
66
62
63
+
:::
67
64
68
-
The spec takes the following fields:
65
+
The `Neo4j` storage exports each row as a relationship to Neo4j Knowledge Graph. The spec takes the following fields:
69
66
70
67
*`connection` (type: [auth reference](../core/flow_def#auth-registry) to `Neo4jConnectionSpec`): The connection to the Neo4j database. `Neo4jConnectionSpec` has the following fields:
71
68
*`uri` (type: `str`): The URI of the Neo4j database to use as the internal storage, e.g. `bolt://localhost:7687`.
72
69
*`user` (type: `str`): Username for the Neo4j database.
73
70
*`password` (type: `str`): Password for the Neo4j database.
74
71
*`db` (type: `str`, optional): The name of the Neo4j database to use as the internal storage, e.g. `neo4j`.
75
-
*`rel_type` (type: `str`): The type of the relationship.
76
-
*`source`/`target` (type: `Neo4jRelationshipEndSpec`): The source/target node of the relationship, with the following fields:
77
-
*`label` (type: `str`): The label of the node.
78
-
*`fields` (type: `list[Neo4jFieldMapping]`): Map fields from the collector to nodes in Neo4j, with the following fields:
79
-
*`field_name` (type: `str`): The name of the field in the collected row.
80
-
*`node_field_name` (type: `str`, optional): The name of the field to use as the node field. If unspecified, will use the same as `field_name`.
81
-
*`nodes` (type: `dict[str, Neo4jRelationshipNodeSpec]`): This configures indexes for different node labels. Key is the node label. The value `Neo4jRelationshipNodeSpec` has the following fields to configure [storage indexes](../core/flow_def#storage-indexes) for the node.
82
-
* `primary_key_fields` is required.
83
-
* `vector_indexes` is also supported and optional.
72
+
*`mapping`: The mapping from collected row to nodes or relationships of the graph. 2 variations are supported:
73
+
*`cocoindex.storages.GraphNode`: each collected row is mapped to a node in the graph. It has the following fields:
74
+
*`label`: The label of the node.
75
+
*`cocoindex.storages.GraphRelationship`: each collected row is mapped to a relationship in the graph,
76
+
With the following fields:
77
+
78
+
*`rel_type` (type: `str`): The type of the relationship.
79
+
*`source`/`target` (type: `cocoindex.storages.GraphRelationshipEnd`): The source/target node of the relationship, with the following fields:
80
+
*`label` (type: `str`): The label of the node.
81
+
*`fields` (type: `list[cocoindex.storages.GraphFieldMapping]`): Map fields from the collector to nodes in Neo4j, with the following fields:
82
+
*`field_name` (type: `str`): The name of the field in the collected row.
83
+
*`node_field_name` (type: `str`, optional): The name of the field to use as the node field. If unspecified, will use the same as `field_name`.
84
+
85
+
:::info
86
+
87
+
All fields specified in `fields` will be mapped to properties of source/target nodes. All remaining fields will be mapped to relationship properties by default.
88
+
89
+
:::
90
+
91
+
* `nodes` (type: `dict[str, cocoindex.storages.GraphRelationshipNode]`): This configures indexes for different node labels. Key is the node label. The value type `GraphRelationshipNode` has the following fields to configure [storage indexes](../core/flow_def#storage-indexes) for the node.
92
+
* `primary_key_fields` is required.
93
+
* `vector_indexes` is also supported and optional.
0 commit comments