Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/neo4j/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/python-2.7/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Neo4j CSV导入状态更新_Neo4j_Cypher - Fatal编程技术网

Neo4j CSV导入状态更新

Neo4j CSV导入状态更新,neo4j,cypher,Neo4j,Cypher,所以我尝试从Mysql数据库迁移到neo4j数据库。对于新的neo4j数据库,我计划了newsfeed特性,正如这里所解释的,这种机制显然不同于mysql,mysql中的newsfeed只是一堆行。那么,有没有办法以-[status\u update]->()-[next]->()-格式将mysql行快速导入neo4j中呢?目前我有一个mysql数据库,如下所示: user table +-------+--------------+ | id | username | +----

所以我尝试从Mysql数据库迁移到neo4j数据库。对于新的neo4j数据库,我计划了newsfeed特性,正如这里所解释的,这种机制显然不同于mysql,mysql中的newsfeed只是一堆行。那么,有没有办法以
-[status\u update]->()-[next]->()-
格式将mysql行快速导入neo4j中呢?目前我有一个mysql数据库,如下所示:

user table
+-------+--------------+
| id    | username     |
+-------+--------------+
| 1     | pewpewlasers |
+-------+--------------+

posts table
+-------+----------+------------+
| id    | user_id  | status     |
+-------+----------+------------+
| 1     | 1        | something  |
+-------+----------+------------+
| 2     | 1        | new update |
+-------+----------+------------+

如果您将其输出为CSV,您可以使用如下方式使用
加载CSV

USING PERIODIC COMMIT 1000
LOAD CSV WITH HEADERS FROM "file:///path/to/file/user.csv" AS line
CREATE (:User {id: toInt(line.id), username: line.username});

USING PERIODIC COMMIT 1000
LOAD CSV WITH HEADERS FROM "file:///path/to/file/posts.csv" AS line
CREATE (:Post {id: toInt(line.id), line.status});

USING PERIODIC COMMIT 1000
LOAD CSV WITH HEADERS FROM "file:///path/to/file/posts.csv" AS line
MATCH (user:User {id: toInt(line.user_id)})
MATCH (post:Post {id: toInt(line.id)})
CREATE user-[:status_update]->post;

USING PERIODIC COMMIT 1000
LOAD CSV WITH HEADERS FROM "file:///path/to/file/posts.csv" AS line
MATCH
  (post:Post {id: toInt(line.id)})
  (previous_post:Post {id: toInt(line.id) - 1})
CREATE previous_post-[:next]->post;
您可能可以组合其中一些查询,但我总是小心地将查询拆分,因为这里提到了一个迫切需要解决的问题:


不得不改变一些事情,但这是个好主意。谢谢