Neo4j使用UNWIND和MATCH性能



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

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

你的想法是这样吗?

它假设您有一个业务。如果每行的业务各不相同,那么烹饪一些东西会更棘手。

// 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

最新更新