I have two specific nodes, that I can identify with unique ids. Super simple - how do I remove a single likes relationship between the two? This doesn't work for some reason, nothing is returned and there is no difference to the data in Neo4J. Note the relationship doesn't have any properties.
MATCH (u:User)-[r:LIKES]-(p:Post)
WHERE u.id="95e54ae5-e512-4030-9640-6b157aaf5400" AND p.id="919f3216-b13b-48ae-a4df-ef779325ff5e"
DELETE r
I've tried this as well, also doesn't work
MATCH (u:User {id: "95e54ae5-e512-4030-9640-6b157aaf5400"})-[r:LIKES]-(p:Post {id: "919f3216-b13b-48ae-a4df-ef779325ff5e"})
DELETE r
The ids are right and truly unique, tried that and didn't work... what's odd is that if I create two new separate nodes that only contain this singular link, that code works
Not sure which relationship or node is preventing me from having this query work as expected. I changed the script to include the right ids btw! Ran this and the output is below:
odd even that didn't work could it be the 'HAS_TAG' relationship going in the other direction somehow interfering?
I don't really know what to doother than slowly add relationships to the node / see which relationship is causing the thing not to delete, but this seems relatively basic and something that people should have run into so I'm very very confused.
Going to put in updates here:
(1) this works, but obvious it deletes all the likes relationships not the specific one I want.
MATCH (u)-[r:LIKES]->(p)
DELETE r
(2) If there are no HAS_TAG relationships coming out of the User node, then I run the above script and it works. See above screenshot, this is as if the only relationship coming out of the User node labeled 'Ali' is LIKES.
(3) When there are only two relationships between that user and the post, HAS_TAG and LIKES as such, I can run that above script and things work...
(u:User)-[:LIKES]->(p:Post)
AND
(u:User)<-[:HAS_TAG]-(p:Post)
(4) BIG ONE - I can't actually remove any LIKES, or HAS_TAG relationships between the node and the post for the node labelled 'ali' in the below photo. The query for deleting any single relationship for a user stops working. Note it was working when there was just the one HAS_TAG and Likes relationship between the post labelled "yooo" and the user node labelled "ali".
In looking at the screen shot where the values are shown on the bottom of the screen, the ID for the User node has a '55' in it, but the value being used in the match query has a '54' in it. It appears the values being used in the query to do the deletion don't match the values in the database.
I tried this example and it worked fine. First creating the data values to delete:
That created the nodes and the relationship.
Added 2 labels, created 2 nodes, set 2 properties, created 1 relationship, completed after 2 ms.
Then they deleted fine using the initial query that was posted:
MATCH (u:User)-[r:LIKES]-(p:Post)
WHERE u.id="95e54ae5-e512-4030-9640-6b157aaf5400" AND p.id="919f3216-b13b-48ae-a4df-ef779325ff5e"
DELETE r
With the results:
Deleted 1 relationship, completed after 2 ms.
Double check the values being passed in as the IDs. On the screen shots were both the query values and database values are shown, the values in the query do not match the values in the database.