如何使用来自一个 table 的 ID 和另一个 JSON 的 ID 在 OrientDB 中使用 JSON 导入 CSV?

How import CSV using JSON in OrientDB using ID from one table and the values of another?

我有 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 个顶点中的 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]

我已经创建了节点。这是我发现难以创建的边缘。我尝试了各种方法。

你可以使用

 "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"
            }
        }
      ],

希望对您有所帮助。