Petar Ivcec
Petar Ivcec

Reputation: 756

cypher query to match all nodes of a specific relationship type to a specific node

I have Author and Articles nodes.

Author has a WROTE relationship that links it to articles.

I would like to get all articles that have been written by an author with a specific uuid.

MATCH (n:Author {uuid: '8f47fb1d-2a3f-46a8-b0fc-06b24169ac86'})<-[:WROTE]-(Article)
RETURN Article

is what I am trying, but it is coming back with (no changes, no records).

Upvotes: 0

Views: 53

Answers (1)

knittl
knittl

Reputation: 265141

I'm guessing here, but the direction of your relationship seems off. You also want to provide the type (i.e. "label") of your article node:

MATCH (n:Author {uuid: '8f47fb1d-2a3f-46a8-b0fc-06b24169ac86'})-[:WROTE]->(a:Article)
RETURN a

For exploring your data and if you do not know the direction, you can match relationships while ignoring the direction:

MATCH (n:Author {uuid: '8f47fb1d-2a3f-46a8-b0fc-06b24169ac86'})-[:WROTE]-(a:Article)
RETURN a

Upvotes: 1

Related Questions