cyphermemgraphdbopencypher

Graph traversing query returns no results


I'm a bit confused by graph traversing queries. After executing:

CREATE (:Node {id: 0});
CREATE (:Node {id: 1});
CREATE (:Node {id: 2});
CREATE (:Node {id: 3});
MATCH (n:Node {id: 0}), (m:Node {id: 1})
CREATE (n)-[:LINK {date: "2023-03"}]->(m);
MATCH (n:Node {id: 1}), (m:Node {id: 2})
CREATE (n)-[:LINK {date: "2023-03"}]->(m);
MATCH (n:Node {id: 2}), (m:Node {id: 3})
CREATE (n)-[:LINK {date: "2023-03"}]->(m);

I want to find paths between Node with id 0 and Node with id 3, so I run next query:

MATCH p = (:Node {id:"0"})-[*]->(:Node {id: "3"})
RETURN p;

and this will return an empty set. Isn't it supposed to return all paths between these two nodes?


Solution

  • You need to match on the integers 0 and 3, not the strings "0" and "3":

    MATCH p = (:Node {id: 0})-[*]->(:Node {id: 3})
    RETURN p;