DSE图形加载器映射边

时间:2017-02-21 11:02:55

标签: datastax-enterprise-graph

我必须将数据从JSON文件映射到DSE。 一切都运行得很好,但我没有找到任何关于如何映射连接到不同节点但共享相同标签的边缘的文档。

示例:

[A:Car] -- [OWNER] --> [B:Person]
[C:Car] -- [OWNER] --> [D:Company]

我尝试了不同的方法,最后我添加了一个明确描述节点类的自定义字段:

数据样本

// Nodes
{"id":"A","label":"Car"}
{"id":"B","label":"Person"}
{"id":"C","label":"Car"}
{"id":"D","label":"Company"}

// Edges
{"out":"A","label":"OWNER","in":"B", "outLabel":"Car","inLabel":"Person"}
{"out":"C","label":"OWNER","in":"D", "outLabel":"Car","inLabel":"Company"}

这是映射脚本

load(nodesInput).asVertices {
     labelField "label"
     key "id"
}

load(edgesInput).asEdges {
    label "OWNER"
    outV "out", {
        key "id"
        label "Car"
    }
    inV "in", {
        key "id"
        labelField "inLabel"  <-- this declaration seems to fail
    }
}

有什么想法吗?

1 个答案:

答案 0 :(得分:2)

我相信你可以用以下内容完成上述工作。

load(edgesInput).asEdges {
    label "OWNER"
    outV "out", {
        key "id"
        label "Car"
    }
    inV "in", {
        key "id"
        label it["inLabel"]
    }
}

https://docs.datastax.com/en/latest-dse/datastax_enterprise/graph/dgl/dglMapScript.html