I am new to orientDB. I want to know how to insert json values from json file into orientDB.
{ "config": {
"log": "debug" }, "source" : {
"file": { "path": "D:\\New folder\\database.json" } }, "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": "D:\\InstalledSoftwares\\orientdb-3.0.8\\databases\\demodb",
"dbUser": "root",
"dbPassword": "vtg@123",
"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" }]
} } }
this is the code i am using to insert json values from json file. If i run this code means it throws an error like
java.lang.IllegalArgumentException: text cannot be null
Can you plz verify this and help me to fix this. Thanks in Advance
I tried your case and it worked
database.json
[
{
"name": "Joe",
"id": 1,
"friends": [2,4,5],
"enemies": [6]
},
{
"name": "Suzie",
"id": 2,
"friends": [1,4,6],
"enemies": [5,2]
}
]
import.json
{
"config": {
"log": "debug"
},
"source" : {
"file": { "path": "database.json" }
},
"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": "remote:localhost/db_name",
"serverUser": "server_username",
"serverPassword": "server_password",
"dbUser": "db_username",
"dbPassword": "db_password",
"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" }]
} } }
then I ran oetl.bat import.json and this is what I get:
select from V
+----+-----+-------+----+-------------+-----+-------+-------+-------------------+-------------+--------+
|# |@RID |@CLASS |id |in_Friend |name |friends|enemies|out_Friend |out_Enemy |in_Enemy|
+----+-----+-------+----+-------------+-----+-------+-------+-------------------+-------------+--------+
|0 |#17:0|Account|2 |[#21:0] |Suzie|[1,4,6]|[5,2] |[#24:0,#21:1,#22:1]|[#26:0,#27:0]|[#27:0] |
|1 |#17:1|Account|6 |[#22:1] | | | | | |[#25:0] |
|2 |#18:0|Account|1 |[#24:0] |Joe |[2,4,5]|[6] |[#21:0,#22:0,#23:0]|[#25:0] | |
|3 |#19:0|Account|4 |[#22:0,#21:1]| | | | | | |
|4 |#20:0|Account|5 |[#23:0] | | | | | |[#26:0] |
+----+-----+-------+----+-------------+-----+-------+-------+-------------------+-------------+--------+
Hope it helps
Regards
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.