This is the data setup:
select * from cypher('test', $$ CREATE (david:Person {name: 'David'})
CREATE (alice:Person {name: 'Alice'})
CREATE (bob:Person {name: 'Bob'})
CREATE (charlie:Person {name: 'Charlie'})
CREATE (eve:Person {name: 'Eve'})
CREATE (david)-[:FRIEND]->(alice)
CREATE (david)-[:FRIEND]->(bob)
CREATE (david)-[:FRIEND]->(charlie)
CREATE (david)-[:FRIEND]->(eve)
CREATE (alice)-[:FRIEND]->(bob)
CREATE (charlie)-[:FRIEND]->(bob)
CREATE (eve)-[:FRIEND]->(frank:Person {name: 'Frank'})
CREATE (frank)-[:FRIEND]->(eve)
CREATE (alice)-[:FRIEND]->(charlie) $$ ) as (a agtype);
Im searching for the query that returns the person that is a friend of David and has 2 or more outgoing relationships. According to the documantation this query should do it:
SELECT *
FROM cypher('graph_name', $$
MATCH (david {name: 'David'})-[]-(otherPerson)-[]->()
WITH otherPerson, count(*) AS foaf
WHERE foaf > 1
RETURN otherPerson.name
$$) as (name agtype);
However this returns Alice, Eve, and Charlie. It is like the WHERE clause is completely ignored. What is the correct query?