我有3个CSV文件:一个用于节点A,一个用于节点B,一个用于边缘A_to_B。
我可以很好地将节点导入OrientDB。这是我遇到问题的边缘。
节点a的CSV文件包含(其中id是整数索引):
id, value
0, a
1, b
2, c
3, d
...
节点b的CSV文件包含(其中id是整数索引):
id, Category
10, cat_x
11, cat_y
12, cat_z
edge_a_b CSV包含:
a_id, Category
0, cat_x
1, cat_z
2, cat_z
...
我可以将两个“a”和“b”正确地放入数据库中。但是,当我运行这个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" }
]
}
}
}
我只得到了我期望匹配的215个顶点中的一个。
| => ./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]
我创建了节点。这是我发现难以创造的边缘。我尝试了各种方法。
答案 0 :(得分:2)
您可以使用
"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"
}
}
],
希望它有所帮助。