I am new to neo4j and I wanted to visualize a json file with its elements relationships. However, I could only success to visualize one part of the file (doc_id=1) using:
CALL apoc.load.json("file:///data/test/forum_test.json")
YIELD value as val
UNWIND val.doc_id as docs
UNWIND val.categs as ctgs
UNWIND ctgs.desc as ctdes
MERGE(node0:docs {doc_nr : val.doc_id})
MERGE(node1:descrp {dess : ctdes.text, label:ctdes.des})
WITH node0, node1
CALL apoc.create.relationship(node0, 'has', {}, node1) YIELD rel
RETURN *
I assume using this commands the visulaized documents will be linked based on ctdes.text
{
"doc_id": 0,
"categs": [
{
"cat_id": 0,
"desc": [
{
"text": "aaa",
"des": "aa"
},
{
"text": "bbb",
"des": "bb"
},
{
"text": "ccc",
"des": "cc"
}
]
},
{
"cat_id": 1,
"desc": [
{
"text": "ddd",
"des": "dd"
},
{
"text": "eee",
"des": "ee"
},
{
"text": "fff",
"des": "ff"
}
]
}
],
"doc_id": 1,
"categs": [
{
"cat_id": 0,
"desc": [
{
"text": "mmm",
"des": "mm"
},
{
"text": "kkk",
"des": "kk"
},
{
"text": "lll",
"des": "ll"
}
]
},
{
"cat_id": 1,
"desc": [
{
"text": "nnn",
"des": "nn"
},
{
"text": "ddd",
"des": "dd"
},
{
"text": "zzz",
"des": "zz"
}
]
}
]
}
fs