簡體   English   中英

如何使用一個表中的ID和另一個表中的值在OrientDB中使用JSON在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"
            }
        }
      ],

希望能幫助到你。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM