2015-02-08 63 views
1

我正在試圖從我一直在MongoDB中保存的大型數據集中進行ETL導入。我已經成功地導入了頂點,並且我覺得自己是一個小語法,也不會從導入邊緣時產生誤解。

我敢肯定,錯誤的是在這個變壓器:

{"edge":{"class":"Friend", "joinFieldName":"id", 
    "lookup": "select from Character WHERE $input.id IN character_friends", 
    "unresolvedLinkAction":"CREATE"}}, 

那麼我現在要做的是,使邊緣與ID文件= FOO到包含FOO的所有其他文件在他們的character_friends數組中。 如果我在瀏覽器中執行

select from Character WHERE FOO IN character_friends 

,我得到一噸的文件,所以我的猜測是,我的問題是$ input.id要麼不返回ID我期待,或可能不被認可作爲一個變量。

文件看起來像這樣:

{ 
    id: FOO, 
    character_friends: [BAR, BAZ, QUX] 
    (and a bunch of other junk) 
} 

回答

2

看來你要插入一個屬性「ID」,但它在藍圖的標準保留。你可以將其重命名(與「場」變壓器)或設置在這個東方裝載機:

standardElementConstraints: false, 

然後我創建這個內容的文件/temp/datasets/charles.json:

[ 
{ 
    name: "Joe", 
    id: 1, 
    friends: [2,4,5], 
    enemies: [6] 
}, 
{ 
    name: "Suzie", 
    id: 2, 
    friends: [1,4,6], 
    enemies: [5,2] 
} 
] 

而且這條管道:

{ 
    config: { 
    log: "debug", 
    parallel: false 
    }, 
    source : { 
    file: { path: "/temp/datasets/charles.json", lock : true } 
    }, 
    extractor : { 
    json: {} 
    }, 
    transformers : [ 
    { merge: { joinFieldName:"id", lookup:"Account.id" } }, 
    { vertex: { class: "Account"} }, 
    { edge: { 
     "class": "Friend", 
     "joinFieldName": "friends", 
     "lookup": "Account.id", 
     "unresolvedLinkAction": "CREATE" 
    } }, 
    { edge: { 
     "class": "Enemy", 
     "joinFieldName": "enemies", 
     "lookup": "Account.id", 
     "unresolvedLinkAction": "CREATE" 
    } } 
    ], 
    loader : { 
    orientdb: { 
     dbURL: "plocal:/temp/databases/charles", 
     dbUser: "admin", 
     dbPassword: "admin", 
     dbAutoDropIfExists: true, 
     dbAutoCreate: true, 
     standardElementConstraints: false, 
     tx: false, 
     wal: false, 
     batchCommit: 1000, 
     dbType: "graph", 
     classes: [{name: 'Account', extends:"V"}, {name: 'Friend', extends:"E"}, {name: 'Enemy', extends:"E"}], 
     indexes: [{class:"Account", fields:["id:integer"], type:"UNIQUE_HASH_INDEX" }] 
    } 
    } 
} 

確保有使用ETL罐子的最後一個版本與默認版本(替換它在$ ORIENTDB/lib目錄)。最後一個版本是從下載:

https://oss.sonatype.org/content/repositories/snapshots/com/orientechnologies/orientdb-etl/2.0.2-SNAPSHOT/orientdb-etl-2.0.2-20150208.225903-1.jar

或者得到OrientDB ETL的主要2.0.2。