如何将以下内容插入neo4j
create (st:serviceticket {name:'SRT_519'})
with st as st
match (st:serviceticket) where st.name='SRT_519'
match (d:ProductID) where d.name ='PRD_1014'
with st as st , d as d
merge (d)-[:SERVICE_TICKETID]->(st);
create (st:serviceticket {name:'SRT_520'})
with st as st
match (st:serviceticket) where st.name='SRT_520'
match (d:ProductID) where d.name ='PRD_1004'
with st as st , d as d
merge (d)-[:SERVICE_TICKETID]->(st);
如果我有多个这样的记录插入如何插入所有这些记录。请帮助我。
答案 0 :(得分:1)
我假设您的产品的节点已经存在。
请记住,您的“st”是一个引用,并且您尝试在一个批次中分配两次相同的引用。 第一步是为您的服务票单提供单独的参考
match (d:ProductID), (e:ProductID)
where d.name ='PRD_1014'and
e.name ='PRD_1004'
create (st519:serviceticket {name:'SRT_519'})
create (st520:serviceticket {name:'SRT_520'})
merge (d)-[:SERVICE_TICKETID]->(st519)
merge (e)-[:SERVICE_TICKETID]->(st520)
答案 1 :(得分:0)
如果使用参数,则可以提供一组对:
你应该有一个索引或约束:ServiceTicket(name)和:ProductID(name)
WITH [['SRT_519','PRD_1014']] as data
FOREACH (pair in data |
MERGE (st:ServiceTicket {name:data[0]}),(d:ProductID {name:data[1]})
MERGE (d)-[:SERVICE_TICKETID]->(st);
)