首页 文章

带有JSON数据文件的OrientDB ETL

提问于
浏览
1

我没有看到关于如何使用OrientDB ETL函数加载JSON data 文件的良好文档 .

我正在运行此命令:./ 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":1}},

The Error I am getting is: 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 data 文件直接加载到OreintDB中 .

谢谢

2 回答

  • 0

    json无效 . 尝试使用www.jsonlint.com进行验证 . 尝试更换:

    {"json"},
    

    附:

    {"json": {} },
    
  • 2

    我不是像Lvca这样的专家,但你的源文件有一个json扩展名 . 这意味着您的提取器必须替换为(“json”:{})并且没有“json”变换器 .

    "extractor" : {
        "json": {}
    },
    "transformers" : [
        { "vertex": { "class": "V" } }
    ],
    

    http://orientdb.com/docs/last/Transformer.html

相关问题