How to use MERGE to create or reuse a part of pattern?

后端 未结 1 348
情深已故
情深已故 2021-01-26 18:03

I have node PRODUCT with multiple REVIEW node. I would create node PRODUCE if the product is not exist, then bind with REVIEW.

For the example, I want a PRODUCE node {n

1条回答
  •  隐瞒了意图╮
    2021-01-26 18:26

    Your subsequent match/merge is redundant. You can do:

    // create/reuse PRODUCT
    MERGE (product:PRODUCT {name:'X phone'})  
    MERGE (product)-[:RATE]-(:REVIEW {content:'nope'})
    MERGE (product)-[:RATE]-(:REVIEW {content:'best phone ever'})
    MERGE (product)-[:RATE]-(:REVIEW {content:'worst phone ever'})
    

    0 讨论(0)
提交回复
热议问题