Hi everyone! I'm very new at Neo4j.
I'm trying to create a graph from a json file that contains the links for the graph and the nodes.
The "links" section has the number of the source node called "ori_val", and the node's number target for this link called "target".
In the "nodes" section lies the "id" label, wich is the number of the corresponding node for creating it, and this "id" number also is the one used in the "links" section for "ori_val" and "target".
Here is an example of the json file for the first node and link (there are 1138 nodes, and 3553 links):
I tried to built the graph by running this code on the cypher, but it only makes links from all the nodes to just two of them, and all the remainig links between the other nodes are missed.
I've also created the nodes from the file with the label "NODOS".
call apoc.load.json("graph.json") yield value
unwind value.links as l
MATCH (n:NODOS) WHERE n.id=l.ori_val
MATCH (s:NODOS) WHERE s.id=l.target
CREATE (n)-[:Incide]->(s)
Sorry if this is an obvious question, but I've spent too many days trying to solve it and I can´t.
Here's an example of how the graph is displayed for the first 25 nodes, and all the links between the remaining nodes are missed (don't pay attention to the "R" relationship).
Thanks for yout help!
Your JSON looks malformed to me [Note: this comment was based on an older version of the question]:
The 0 should be a string and there should be a value after it. Or maybe it should be removed. Or something. Check your log to see if apoc.load.json() complained about your JSON.
Also, the string values after the keys need to be inside quotes. (e.g. "normal" "Guatemala")
Sure, no problem.
I'm trying to build a graph with this json.
First you have the "links" section, this tells you all the links your graph must have, in this example you need to build the link from the node with "id"=3, to the node with "id"=376, and so on with the others 3552 links in this json.
On the other hand, you have the "nodes" section, wich tells you all the nodes you have to create, and its properties like "id", "country", etc. I have already created all the nodes from the "nodes" section, with the label "NODOS".
My problem is when I try to build all the links for all the created nodes. I did it with this code:
call apoc.load.json("graph.json") yield value
unwind value.links as l
MATCH (n:NODOS) WHERE n.id=l.ori_val
MATCH (s:NODOS) WHERE s.id=l.target
CREATE (n)-[:Incide]->(s)
But this only makes the links from all the nodes to just two of them: the once with "Corte Interamericana" label, and the other one labeled with "Convencion Americana sobre Derechos". And the other relationships between the remaining nodes are missing, for example the link between "Caso Godínez" and "Caso Herrera" is missed, and so on.
I need to know what am I missing to make all the relationships between the other nodes?