Using matched node assignments in merge
See original GitHub issueHi,
I’m trying to create a MERGE for a relationship after a MATCH statement, as described in MERGE: neo4j documentation. However I’m having issues re-using the node-assignments.
The query I’m trying to produce is:
MATCH (a:`Article` {`article_id`: '123456'}),(p:`Product` {`product_id`: '1234567'})
MERGE a-[r:BELONGS_TO]->p
However I seem to run into two issues; the first is a multiple match, I tried defining it as:
p.MATCH.node(...).node(...)
this outputs a non comma separated MATCH sequence which turns unusable. How would I achieve a comma separated MATCH sequence (as shown in the referenced documentation)?
Secondly I can’t seem to re-use the assigned node MATCH, in the above case assigned “a”:
p.MERGE.a.rel_out(labels="BELONGS_TO").p
Update What I’m trying to achieve is something similar to this:
MATCH(a:Article{product_id: '1234567'}), (p:Product{product_id: '1234567'})
MERGE (a)-[r:PART_OF]->(p)
RETURN a, r, p
Any ideas on this?
Thank you in advance
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Cypher: How to match node based on property and then set or ...
Whenever we execute a merge query, a node is either matched or created. Using on create and on the match, you can set...
Read more >MERGE - Cypher Manual - Neo4j
Merge with ON MATCH Merging nodes and setting properties on found nodes. The query finds all the Person nodes, sets a property on...
Read more >Match and Merge Documentation - Task 3: Setting up matching
Task 3: Overview. A matching operation compares data from two or more records to find potential duplicates. You create a Matching policy to...
Read more >Merge - execute insert or update when matched depdenidng ...
If you use the 100 4 TRUE row first, this will update the last row in the target table. It will change the...
Read more >MERGE (preview) - Amazon Redshift
Next, merge the source table into the target table, updating the target table with matching rows and insert rows from the source table...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Edit: as you can see my return statement is wrong. You need to do it the way I described, with parens
The best way to handle this is to use the
Anon
class –__
and to executeMATCH
with par’sYou can add parens to all of the statements and it will generate a list of comma-separated items https://github.com/emehrkay/Pypher#statement