From d51640f9e54dce9cceacbd879363bb3ae460ceec Mon Sep 17 00:00:00 2001 From: Josip Mrden Date: Mon, 24 Mar 2025 15:08:07 +0100 Subject: [PATCH 1/3] Add migration from Neo4 --- .../available-algorithms/migrate.mdx | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/pages/advanced-algorithms/available-algorithms/migrate.mdx b/pages/advanced-algorithms/available-algorithms/migrate.mdx index dccec6d37..156916836 100644 --- a/pages/advanced-algorithms/available-algorithms/migrate.mdx +++ b/pages/advanced-algorithms/available-algorithms/migrate.mdx @@ -98,6 +98,61 @@ CREATE (u1)-[:FRIENDS_WITH]->(u2); --- +### `neo4j()` + +With the `migrate.neo4j()` procedure, you can access Neo4j and migrate your data to Memgraph. +The resulting nodes and edges are converted into a stream of rows which can include labels, properties, and primitives. +**Streaming of raw node and relationship objects is not supported**, and users are advised to migrate all the necessary identifiers +in order to recreate the same graph in Memgraph. + +{

Input:

} + +- `label_or_rel_or_query: str` ➡ Label name (written in format `(:Label)`), relationship name (written in format `[:rel_type]`) or a plain cypher query. +- `config: mgp.Map` ➡ Connection parameters (as in `gqlalchemy.Neo4j`). Notable parameters are `host[String]`, and `port[Integer]` +- `config_path` ➡ Path to a JSON file containing configuration parameters. +- `params: mgp.Nullable[mgp.Any] (default=None)` ➡ Query parameters (if applicable). + +{

Output:

} + +- `row: mgp.Map` ➡ The result table as a stream of rows. + - when retrieving nodes using the `(:Label)` syntax, row will have the following keys: `labels`, and `properties` + - when retrieving relationships using the `[:REL_TYPE]` syntax, row will have the following keys: `from_labels`, `to_labels`, `from_properties`, `to_properties`, and `edge_properties` + - when retrieving results using a plain Cypher query, row will have keys identical to the returned column names from the Cypher query + +{

Usage:

} + +#### Retrieve nodes of certain label and create them in Memgraph +```cypher +CALL migrate.neo4j('(:Person)', {host: 'localhost', port: 7687}) +YIELD row +WITH row.labels AS labels, row.properties as props +CREATE (n:labels) SET n += row.props +``` + +#### Retrieve relationships of certain type and create them in Memgraph +```cypher +CALL migrate.neo4j('[:KNOWS]', {host: 'localhost', port: 7687}) +YIELD row +WITH row.from_labels AS from_labels, + row.to_labels AS to_labels, + row.from_properties AS from_properties, + row.to_properties AS to_properties, + row.edge_properties AS edge_properties +MATCH (p1:Person {id: row.from_properties.id}) +MATCH (p2:Person {id: row.to_properties.id}) +CREATE (p1)-[r:KNOWS]->(p2) +SET r += edge_properties; +``` + +#### Retrieve information from Neo4j using an arbitrary Cypher query +```cypher +CALL migrate.neo4j('MATCH (n) RETURN count(n) as cnt', {host: 'localhost', port: 7687}) +YIELD row +RETURN row.cnt as cnt; +``` + +--- + ### `oracle_db()` With the `migrate.oracle_db()` procedure, you can access Oracle DB and migrate your data to Memgraph. From ec7bbab345d52a2be993e5c4c681131b2c5a5ca1 Mon Sep 17 00:00:00 2001 From: katarinasupe Date: Thu, 27 Mar 2025 09:58:53 +0100 Subject: [PATCH 2/3] add info to data migration --- pages/data-migration.mdx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pages/data-migration.mdx b/pages/data-migration.mdx index 5a8cccc0b..5e068678a 100644 --- a/pages/data-migration.mdx +++ b/pages/data-migration.mdx @@ -72,7 +72,12 @@ Lab or mgconsole](/data-migration/cypherl). ## Neo4j Export the data into a CSV file and import it into Memgraph using the LOAD CSV -clause, like in this [example](/data-migration/migrate-from-neo4j). +clause, like in this [example](/data-migration/migrate-from-neo4j). + +Alternatively, you can use the [`migrate` +module](/advanced-algorithms/available-algorithms/migrate) which allows you to +[access data from a Neo4j +database](/advanced-algorithms/available-algorithms/migrate#neo4j). ## Data from an application or a program From 12a6d7b840310d22995cf6b39dd587333b2b909e Mon Sep 17 00:00:00 2001 From: katarinasupe Date: Thu, 27 Mar 2025 09:59:43 +0100 Subject: [PATCH 3/3] small fixes --- .../advanced-algorithms/available-algorithms/migrate.mdx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pages/advanced-algorithms/available-algorithms/migrate.mdx b/pages/advanced-algorithms/available-algorithms/migrate.mdx index 156916836..ec7f6c3ad 100644 --- a/pages/advanced-algorithms/available-algorithms/migrate.mdx +++ b/pages/advanced-algorithms/available-algorithms/migrate.mdx @@ -108,16 +108,16 @@ in order to recreate the same graph in Memgraph. {

Input:

} - `label_or_rel_or_query: str` ➡ Label name (written in format `(:Label)`), relationship name (written in format `[:rel_type]`) or a plain cypher query. -- `config: mgp.Map` ➡ Connection parameters (as in `gqlalchemy.Neo4j`). Notable parameters are `host[String]`, and `port[Integer]` +- `config: mgp.Map` ➡ Connection parameters (as in `gqlalchemy.Neo4j`). Notable parameters are `host[String]` and `port[Integer]`. - `config_path` ➡ Path to a JSON file containing configuration parameters. - `params: mgp.Nullable[mgp.Any] (default=None)` ➡ Query parameters (if applicable). {

Output:

} - `row: mgp.Map` ➡ The result table as a stream of rows. - - when retrieving nodes using the `(:Label)` syntax, row will have the following keys: `labels`, and `properties` - - when retrieving relationships using the `[:REL_TYPE]` syntax, row will have the following keys: `from_labels`, `to_labels`, `from_properties`, `to_properties`, and `edge_properties` - - when retrieving results using a plain Cypher query, row will have keys identical to the returned column names from the Cypher query + - When retrieving nodes using the `(:Label)` syntax, row will have the following keys: `labels` and `properties`. + - When retrieving relationships using the `[:REL_TYPE]` syntax, row will have the following keys: `from_labels`, `to_labels`, `from_properties`, `to_properties` and `edge_properties`. + - When retrieving results using a plain Cypher query, row will have keys identical to the returned column names from the Cypher query. {

Usage:

}