[英]How import CSV using JSON in OrientDB using ID from one table and the values of another?
I have 3 CSV files: one for node A, one for node B and one for edge A_to_B. 我有3个CSV文件:一个用于节点A,一个用于节点B,一个用于边缘A_to_B。
I can import the nodes into OrientDB just fine. 我可以将节点导入OrientDB中就好了。 It's the edges that I'm having problems with.
这是我遇到的问题。
node a's CSV file contains (where id is integer index): 节点a的CSV文件包含(其中id为整数索引):
id, value
0, a
1, b
2, c
3, d
...
node b's CSV file contains (where id is a integer index): 节点b的CSV文件包含(其中id是整数索引):
id, Category
10, cat_x
11, cat_y
12, cat_z
edge_a_b CSV contains: edge_a_b CSV包含:
a_id, Category
0, cat_x
1, cat_z
2, cat_z
...
I can get the two "a" and "b" properly into the database. 我可以将两个“ a”和“ b”正确地放入数据库中。 However, when I run this ETL json...
但是,当我运行此ETL json时...
{
"source": { "file": { "path": "/mypath/edge_a_b.csv" } },
"extractor": { "csv": {} },
"transformers": [
{ "vertex": { "class": "b", "skipDuplicates": true } },
{ "edge": { "class": "Involves", "joinFieldName": "a_id", "lookup": "a.id", "direction": "in" } }
],
"loader": {
"orientdb": {
"dbURL": "plocal:../databases/mydb",
"dbType": "graph",
"classes": [
{"name": "a", "extends": "V"},
{"name": "b", "extends": "V"},
{"name": "Involves", "extends": "E"}
], "indexes": [
{"class":"a", "fields":["id:integer"], "type":"UNIQUE" },
{"class":"b", "fields":["id:integer"], "type":"UNIQUE" }
]
}
}
}
I only get 1 of the 215 vertices I'm expecting matched. 我只得到期望的215个顶点中的1个。
| => ./oetl.sh /mypath/edge_a_b.json
OrientDB etl v.2.2.11 (build 2.2.x@r8b3a478e3ca7321a48e7cf0f5991569bbe06ed89; 2016-10-03 09:39:41+0000) www.orientdb.com
BEGIN ETL PROCESSOR
[file] INFO Reading from file /mypath/edge_a_b.csv with encoding UTF-8
Started execution with 1 worker threads
[orientdb] INFO committing
END ETL PROCESSOR
+ extracted 215 rows (0 rows/sec) - 215 rows -> loaded 1 vertices (0 vertices/sec) Total time: 172ms [0 warnings, 0 errors]
I have the nodes created. 我创建了节点。 It's the edges that I'm finding difficult to create.
这是我发现很难创建的边缘。 I've tried various approaches.
我尝试了各种方法。
You could use 你可以用
"extractor": {"row": {}},
"transformers": [{
"csv": {
"separator": ","
}
},
{
"command" : {
"command" : "create edge Involves from (select from a where id= ${input.a_id}) to (select from b where Category= '${input.Category}')",
"output" : "edge"
}
}
],
Hope it helps. 希望能帮助到你。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.