我没有看到关于如何使用OrientDB ETL函数加载JSON 数据文件的良好文档。
我正在运行此命令:./ oetl.sh ../template_etl.json
template_etl.json的内容如下所示:
{
"config": {
"log": "debug"
},
"begin": [
],
"source" : {
"file": {"path": "../repos.json", "lock" : true }
},
"extractor" : {
"row": {}
},
"transformers" : [
{"json"},
{ "vertex": { "class": "V" } }
],
"loader" : {
"orientdb": {
"dbURL": "plocal../databases/template",
"dbUser": "admin",
"dbPassword": "admin",
"dbAutoCreate": true,
"tx": false,
"batchCommit": 1000,
"dbType": "graph"
}
}
}
我从https://www.udemy.com/orientdb-getting-started/#/lecture/1998370的csv示例中获取此示例,其中此行:{" json"}最初是:{" csv":{" separator":","," multiValue":" NULL"," skipFrom":1," skipTo&# 34;:1}},
我得到的错误是: orientdb-community-2.0 / bin $ ./oetl.sh ../ template_etl.json
OrientDB etl v.2.0 (build @BUILD@) www.orientechnologies.com
Exception in thread "main" com.orientechnologies.orient.core.exception.OSerializationException: Error on unmarshalling JSON content for record: "config": {
"log": "debug"
},
"begin": [
],
"source" : {
"file": {"path": "../repos.json", "lock" : true }
},
"extractor" : {
"row": {}
},
"transformers" : [
{"json"},
{ "vertex": { "class": "V" } }
],
"loader" : {
"orientdb": {
"dbURL": "plocal../databases/template",
"dbUser": "admin",
"dbPassword": "admin",
"dbAutoCreate": true,
"tx": false,
"batchCommit": 1000,
"dbType": "graph"
}
}
at com.orientechnologies.orient.core.serialization.serializer.record.string.ORecordSerializerJSON.fromString(ORecordSerializerJSON.java:304)
at com.orientechnologies.orient.core.record.ORecordAbstract.fromJSON(ORecordAbstract.java:165)
at com.orientechnologies.orient.core.record.impl.ODocument.fromJSON(ODocument.java:1712)
at com.orientechnologies.orient.etl.OETLProcessor.main(OETLProcessor.java:147)
Caused by: com.orientechnologies.orient.core.exception.OSerializationException: Error on unmarshalling JSON content: wrong format ""json"". Use <field> : <value>
at com.orientechnologies.orient.core.serialization.serializer.record.string.ORecordSerializerJSON.fromString(ORecordSerializerJSON.java:181)
at com.orientechnologies.orient.core.serialization.serializer.record.string.ORecordSerializerJSON.getValueAsRecord(ORecordSerializerJSON.java:595)
at com.orientechnologies.orient.core.serialization.serializer.record.string.ORecordSerializerJSON.getValueAsObjectOrMap(ORecordSerializerJSON.java:565)
at com.orientechnologies.orient.core.serialization.serializer.record.string.ORecordSerializerJSON.getValue(ORecordSerializerJSON.java:413)
at com.orientechnologies.orient.core.serialization.serializer.record.string.ORecordSerializerJSON.parseCollection(ORecordSerializerJSON.java:677)
at com.orientechnologies.orient.core.serialization.serializer.record.string.ORecordSerializerJSON.getValueAsEmbeddedCollection(ORecordSerializerJSON.java:659)
at com.orientechnologies.orient.core.serialization.serializer.record.string.ORecordSerializerJSON.getValueAsCollection(ORecordSerializerJSON.java:638)
at com.orientechnologies.orient.core.serialization.serializer.record.string.ORecordSerializerJSON.getValue(ORecordSerializerJSON.java:415)
at com.orientechnologies.orient.core.serialization.serializer.record.string.ORecordSerializerJSON.fromString(ORecordSerializerJSON.java:249)
... 3 more
我希望有办法将JSON 数据文件直接加载到OreintDB中。
由于
答案 0 :(得分:2)
json无效。尝试使用www.jsonlint.com进行验证。尝试更换:
{"json"},
使用:
{"json": {} },
答案 1 :(得分:0)
我没有像Lvca这样的专家,但你的源文件有一个json扩展名。这意味着您的提取器必须替换为(&#34; json&#34;:{})并且没有&#34; json&#34;变压器。
"extractor" : {
"json": {}
},
"transformers" : [
{ "vertex": { "class": "V" } }
],