Head's Up! Site maintenance this Wednesday, February 1. Disruptions expected as we migrate the forums.
β08-07-2022 01:46 AM
LOAD CSV WITH HEADERS FROM "file:///kandidatpilpres_tesis3.csv" as nodes
create (n {name: nodes.vertex, type: nodes.Rela})
MERGE (tgt10:Char0a {id: nodes.target})
MERGE (ver10:Char0a {id: nodes.vertex})
match (y {type:"Tweet"})
set y:Tweet
match (x {type:"Mentions"})
set x:Mentions
match (z {type:"Replies_to"})
set z:Replies_to
MERGE (tgt)-[:Mentions]->(x)
MERGE (tgt)-[:Tweet]->(y)
MERGE (tgt)-[:Replies_to]->(z)
RETURN *
Solved! Go to Solution.
β08-07-2022 06:16 AM
You can try this if you want to use pure cypher:
load csv with headers from "file:///TargetVertexImport.csv" as row
merge(v:Vertx{name: row.vertex})
merge(t:Target{name: row.target})
with v, t, row
call{
with v, t, row
with v, t, row
where row.Rela1 = 'Mentions'
merge(t)-[:MENTIONS]->(v)
}
call{
with v, t, row
with v, t, row
where row.Rela1 = 'Replies_to'
merge(t)-[:REPLIES_TO]->(v)
}
Or try this, if you are ok with using the apoc library. The code is more compact and does not require a new call block for every different relationship type.
load csv with headers from "file:///TargetVertexImport.csv" as row
merge(v:Vertx{name: row.vertex})
merge(t:Target{name: row.target})
with t, v, row
call apoc.create.relationship(t, toUpper(row.Rela1), null, v) yield rel
return t.name, v.name, type(rel)
β08-07-2022 04:17 AM - edited β08-07-2022 04:20 AM
I have three observations. One, you will need a βwithβ statement when going from a βmergeβ or βcreateβ to a βmatchβ, and also when going from a βsetβ to a βmatchβ. Two, you are referencing variable βtgtβ in your final three βmergeβ statements, but I done see βtgtβ being set. As a result, the merge will create a new node on the first βmergeβ, which will be used in the following two merges. Is this your intent, or did you want to reference βtgt10β instead? Three, why are you matching and setting the label for the three nodes βTweetβ, βMentionsβ, and βReplies_toβ in this import query? That should be done once outside this query if there was an error when those nodes where first created. You still need to match here for use in your final three βmerges.β
You could fix it to execute by inserting βwith *β in each of the places I mentioned.
β08-07-2022 04:42 AM
LOAD CSV WITH HEADERS FROM "file:///kandidatpilpres_tesis3.csv" as nodes
create (n {name: nodes.vertex, type: nodes.Rela})
MERGE (tgt:Char0a {id: nodes.target})
MERGE (ver:Char0a {id: nodes.vertex})
match (y {type:"Tweet"})
set y:Tweet
match (x {type:"Mentions"})
set x:Mentions
match (z {type:"Replies_to"})
set z:Replies_to
MERGE (tgt)-[:Mentions]->(x)
MERGE (tgt)-[:Tweet]->(y)
MERGE (tgt)-[:Replies_to]->(z)
RETURN *
==============
yes, really refers to tgt,
I will try the instructions
==============
β08-07-2022 04:54 AM
I want to make target relation to vertex with relation according to Rela1
I'm having trouble making this
β08-07-2022 06:16 AM
You can try this if you want to use pure cypher:
load csv with headers from "file:///TargetVertexImport.csv" as row
merge(v:Vertx{name: row.vertex})
merge(t:Target{name: row.target})
with v, t, row
call{
with v, t, row
with v, t, row
where row.Rela1 = 'Mentions'
merge(t)-[:MENTIONS]->(v)
}
call{
with v, t, row
with v, t, row
where row.Rela1 = 'Replies_to'
merge(t)-[:REPLIES_TO]->(v)
}
Or try this, if you are ok with using the apoc library. The code is more compact and does not require a new call block for every different relationship type.
load csv with headers from "file:///TargetVertexImport.csv" as row
merge(v:Vertx{name: row.vertex})
merge(t:Target{name: row.target})
with t, v, row
call apoc.create.relationship(t, toUpper(row.Rela1), null, v) yield rel
return t.name, v.name, type(rel)
β08-07-2022 06:43 AM
thank you very much
can run
All the sessions of the conference are now available online