绑定完请刷新页面
取消
刷新

分享好友

×
取消 复制
从CSV到GraphDB
2022-06-23 10:38:18

目录

内文

一、目标:

二、输入:

三、执行:

四、输出:

五、参考:

内文
一、目标:
从csv档汇入Graph Db(Neo4j、ArangoDB、OrientDB)Couple

二、输入:
PERSON-资料

Relationships (parent,spouse) -关系

三、执行:
Neo4j

query

POST /db/data/transaction/commit(默认数据库),/db/mydb/tx/commit

{

"statements" :

[

{

"statement" : "match (n:PERSON {ID:$Id})-[r:PARENT|SPOUSE *..3] -(x) return * limit 100",

"parameters" : {

"nodeId" : "${id}"

},

"resultDataContents" : [ "row", "graph" ]

}

]

}

import

"bin/neo4j-admin import \

--nodes=import/node_a--relationships=import/rel_a \

--relationships

=import/rel_b \

--skip-bad-relationships=true \

--skip-duplicate-nodes=true \

--database= mydb"

ArangoDB

查询

POST /_api/cursor

{

"query" : "FOR n IN PERSON FILTER n.ID=='${id}' FOR v, e, p IN 1..3 ANY n GRAPH myGraph LIMIT 100 RETURN p ",

"count" : true

}

导入节点

bin/arangoimp --file "/path/file.csv" \

--type csv \

--collection "NODE" \

--server.username user \

--server.password pwd \

--translate "_ID:ID=_key" \

--translate ":TYPE=type" \

--separator=","

导入边

bin/arangoimp - -file "/path/rel_file.csv" \

--type csv \

--collection "EDGE" \

--server.username user \

--server.password pwd \

--separator="," \

--translate ": START_ID=_from" \

--translate ":END_ID=_to" \

--translate ":TYPE=type" \

--translate "LABEL=desc" \

--from-collection-prefix NODE \

--to-collection-prefix NODE \

--ignore-missing true

OrientDB

查询

GET /query/mydb/sql/

SELECT FROM (TRAVERSE in(),out() FROM (SELECT FROM PERSON WHERE ID='$id') MAXDEPTH 3)

导入节点

{

"source ": { "file": { "path": "/path/node.csv" } },

"extractor": { "csv": {} },

"transformers": [

{ "vertex": { "class" : "NODE" } }

],

"loader": {

"orientdb": {

"dbURL": "plocal:/path/databases/db",

"dbUser": "Admin",

"dbPassword": "xxxx",

" dbAutoCreate": true,

"dbType": "graph",

"classes": [

{"name": "NODE", "extends": "V"},

{"name": "EDGE", "extends": " E"}

], "indexes": [

{"class":"PERSON", "fields":["_ID_ID:string"], "type":"UNIQUE" }

]

}

}

}

导入边
{

"source": {“文件”:{“路径”:“/path/edge.csv”}},

“提取器”:{“cs v": {} },

"transformers": [

{ "merge": { "joinFieldName": "_START_ID", "lookup": "V._ID_ID", "unresolvedLinkAction": "SKIP" } },

{ "vertex" : { "class": "NODE", "skipDuplicates": true } },

{ "edge": {

"class": "EDGE",

"joinFieldName": "_END_ID",

"lookup": "V._ID_ID",

"direction": "out"

}

}

],

"loader": {

"orientdb": {

"dbURL": "plocal:/path/databases/db",

"dbUser": "Admin",

"dbPassword": "xxxx ",

"dbAutoCreate": true,

"dbType": "graph",

"classes": [

{"name": "NODE", "extends": "V"},

{"name": "EDGE", "extends ": "E"}

], "indexes": [

{"class":"NODE", "fields":["_ID_ID:string"], "type":"UNIQUE" }

]

}

}

}

ArangoDB需要

在shell中模式才能建立较复杂的图,

汇入csv 时需需要关系要与节点的对应关系,

可以转移栏位名称

OrientDB

使用ETL模式汇入数据



四、输出:
neo4j




arangodb




orientdb




五、参考:
https:/ /www.arangodb.com/docs/stable/programs-arangoimport-examples-csv.html

https://www.arangodb.com/docs/stable/graphs-general-graphs.html

https://www.arangodb.com /2020/05/best-practices-for-aql-graph-queries/

https://neo4j.com/docs/operat ions-manual/current/tools/neo4j-admin-import/

https://neo4j.com/docs/operations-manual/current/tutorial/neo4j-admin-import/

https://neo4j.com/docs/http- api/current/actions/begin-a-transaction/

http://orientdb.org/docs/3.0.x/etl/Loader.html

https://orientdb.org/docs/3.1.x/misc/OrientDB-REST .html

https://stackoverflow.com/questions/33679571/how-to-use-orientdb-etl-to-create-edges-only
————————————————
版权声明:本文为CSDN博主「Jpx23」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/m0_50215130/article/details/118219270

分享好友

分享这个小栈给你的朋友们,一起进步吧。

GraphDB
创建时间:2022-04-18 10:29:03
GraphDB
展开
订阅须知

• 所有用户可根据关注领域订阅专区或所有专区

• 付费订阅:虚拟交易,一经交易不退款;若特殊情况,可3日内客服咨询

• 专区发布评论属默认订阅所评论专区(除付费小栈外)

技术专家

查看更多
  • LCR_
    专家
戳我,来吐槽~