using Community Edition 2.1.11
I saw some similar questions on the Internet (ex., import edges to OrientDB using etl or orient-database.narkive.com/d8c4b82y/orientdb-etl-edge-creation-help), but they are not really resolved yet.
I'm implementing the flight connection search system. I have RDBMS (SQL Server) with two related tables - Locations and Flights. Each flight carries two locationIDs - locationFrom and locationTo.
When I import it to the graph, I want to see locations as vertices, connected with flights as edges. As I understood from the manual (Import-from-DBMS, I cannot post more than two links due to newbie limitations...), I should write two different JSONs for this purpose and run them by ETL. So, I can import the locations without any problem with this code:
{
"config": {
log : "debug"
},
"extractor" : {
"jdbc": { "driver": "com.microsoft.sqlserver.jdbc.SQLServerDriver",
"url": "jdbc:sqlserver://localhost:1434;databaseName=mydb;integratedSecurity=true;",
"userName": "root",
"userPassword": "root",
"query": "select * from locations" }
},
"transformers" : [
{ "vertex": { "class": "Location"} }
],
"loader" : {
"orientdb": {
"dbURL": "plocal:C:\orientdb-community-2.1.11\databases\Test",
dbUser: "admin",
dbPassword: "admin",
dbAutoDropIfExists: false,
dbAutoCreate: true,
tx: false,
wal: false,
batchCommit: 1000,
dbType: "graph",
indexes: [{class:"Location", fields:["id:string"], type:"UNIQUE_HASH_INDEX" }]
}
}
}
But when I try to import flights, I get into a problem, that I couldn't resolve even with the Google's help: the ETL does not want to import edges only. As a first intuitive purpose, I wrote something like that:
{
"config": {
log : "debug"
},
"extractor" : {
"jdbc": { "driver": "com.microsoft.sqlserver.jdbc.SQLServerDriver",
"url": "jdbc:sqlserver://localhost:1434;databaseName=mydb;integratedSecurity=true;",
"userName": "root",
"userPassword": "root",
"query": "select * from flights" }
},
"transformers" : [
{ "edge": { "class": "flight", "direction" : "out",
"joinFieldName": "flightFromLocation",
"lookup":"locationID", "unresolvedLinkAction":"CREATE"}
{ "class": "flight", "direction" : "in",
"joinFieldName": "flightToLocation",
"lookup":"locationID", "unresolvedLinkAction":"CREATE"}
}
],
"loader" : {
"orientdb": {
"dbURL": "plocal:C:\orientdb-community-2.1.11\databases\Test",
dbUser: "admin",
dbPassword: "admin",
dbAutoDropIfExists: false,
dbAutoCreate: true,
tx: false,
wal: false,
batchCommit: 1000,
dbType: "graph",
indexes: [{class:"flight", fields:["id:string"], type:"UNIQUE_HASH_INDEX" }]
}
}
}
In one of the threads in OrientDB's GoogleGroups I've found a post from Luca from OrientDB, that says that load only edges IS possible through ETL, but I still can not figure out, how to achieve it :( the only idea I have after two days of reading docs and googling is to import them as vertices, and then write some console JS function that will create the proper edges with the same properties...
Or maybe I'm missing something very basic? I'm totally new to Orient...