Neo4j使用带有MATCH性能的UNWIND

时间:2017-07-09 21:31:46

标签: neo4j cypher

尝试创建UNWIND查询以解析列表。 MATCH查询正在列表中的每一行运行。有没有办法让MATCH查询只运行一次,然后使用每行的值?我们尝试了DISTINCT但失败了。

UNWIND ${PACBatch} AS row
MATCH (e:Business {serial_number: row.ownerID})
CREATE (p:Person {serial_number: row.tempSerial, created: 
row.rowCreated})
CREATE (e)-[r:SELLS_ITEM {created: row.rowUpdated}]->(p)
RETURN p AS PER, r AS OWNS

1 个答案:

答案 0 :(得分:2)

你有什么想法吗?

它假设您只有一项业务。如果每行的业务不同,那么做饭就更难了。

// match the business node
MATCH (e:Business {serial_number: a_particular_ownerID })
WITH e

// then bring the business node forward and process each row in the UNWIND
UNWIND ${PACBatch} AS row
CREATE (p:Person {serial_number: row.tempSerial, created: row.rowCreated})
CREATE (e)-[r:SELLS_ITEM {created: row.rowUpdated}]->(p)
RETURN p AS PER, r AS OWNS