Sunny
Sunny

Reputation: 127

Add Edge Property ithrough Orientdb ETL

I have 2 csv files.

Person.csv

ID,PetID,Jumps
1,101,Yes
2,102,No
3,103,Yes

Pet.csv

ID,Name
101,Dog
102,Cat
103,Rabbit

I am writing ETL to populate my graph with these two entities. I want to add an edge between Person and Pet as HAS_PET. And i also want this edge to have property called Jumps. How can i achieve this ?

I tried as follows,

{
    "source":{
        "file":{
            "path":"C:/Users/60886/Project/person.csv"
        }
    },


    "extractor":{
        "row":{

        }
    },


    "transformers":[
        {
            "csv":{

            }
        },
        {
            "vertex":{
                "class":"Person"
            }
        },
        {
            "edge":{
                "class":"HAS_PET",
                "joinFieldName":"PETID",
                "lookup":"PET.ID",
                "direction":"out",
                "unresolvedLinkAction":"NOTHING"
            }
        }
    ],
    "loader":{
        "orientdb":{
            "dbURL":"remote:localhost/GratefulDeadConcerts",
            "dbType":"graph",
            "wal":false,
            "tx":false,
            "batchCommit":1000
        }
    }
}

Upvotes: 4

Views: 795

Answers (1)

Lvca
Lvca

Reputation: 9060

In edge transformer use edgeFields to bind properties in edges. Example:

"edge":{
   "class":"HAS_PET",
   "joinFieldName":"PETID",
   "lookup":"PET.ID",
   "direction":"out",
   "edgeFields": { "Jumps": "${input.Jumps}" },
   "unresolvedLinkAction":"NOTHING"
}

Remember to remove "Jumps" from vertex, after the edge transformer, with:

"field": { "fieldName": "Jump", "operation": "remove" },

Upvotes: 2

Related Questions