Avoid duplication of node where looping into an json array in Cypher QL

时间:2019-04-08 13:24:03

标签: json neo4j cypher

I'm very new to cypher QL and neo4j. I want to use it to parse and expose data from books such as key thoughts and tags associate to it.

Unfortunately, the tags are duplicated, and I don't very understand how to use MERGE command on this case.

The JSON I created from my book is here : https://raw.githubusercontent.com/Winael/neo4j/master/management3.0/les-entreprises-humanistes.json

and I'm trying to write a Cypher parser for it : https://raw.githubusercontent.com/Winael/neo4j/master/management3.0/les-entreprises-humanistes_V2.cql

That I would like to have is a tag node related to all the nodes tagged, that will help me to navigate more easily through my book and link key thoughts

Is there someone that could help me please ?

1 个答案:

答案 0 :(得分:1)

Being specific to avoid the tags duplication:

You should separate this:

MERGE (t:TAG {tag:tag})-[:tag]->(kt)

Into two statements as shown below:

MERGE (t:TAG {tag:tag})
MERGE (t)-[:tag]->(kt)

You can read about using merge effectively here.