Subtle bug in "Introduction to neo4j part 5"?

I really think the online training is fantastic, thanks to anyone/everyone involved in putting it together! I believe I've encountered an inconsistency in one of the examples. I'm mentioning it because either A) I may help correct a small error -or- B) I'll learn something from my mistake/misunderstanding.

Under the topic " Testing with patterns" the first query is described as " Here is an example where we want to return all Person nodes of people who wrote movies:". The Cypher for this is:

MATCH (p:Person)-[:WROTE]->(m:Movie)
RETURN, m.title

We're good up until this point.

The next step is described as "Next, we modify this query to exclude people who directed that movie:" and the Cypher in the training for this is:

MATCH (p:Person)-[:WROTE]->(m:Movie)
WHERE NOT exists( (p)-[:DIRECTED]->() )
RETURN, m.title

I think the anonymous node in the WHERE clause is incorrect. This causes all people who have directed ANY movie to be excluded. For example, Nora Ephron wrote "When Harry Met Sally" but did not direct it. She directed "You've Got Mail". Nora is filtered out of the result set with the Cypher provided.

To match the description, I believe the Cypher should be:

MATCH (p:Person)-[:WROTE]->(m:Movie)
WHERE NOT exists( (p)-[:DIRECTED]->(m) )
RETURN, m.title

Alternately, you can keep the Cypher the same and change the description of that step to "Next, we modify this query to exclude people who directed any movie:"

Hello and thank you for catching this!

The key here is "that" movie. The anonymous node should not be used, but rather the specific node, m.

We will update the course materials.


1 Like

The Cypher is updated in the course materials already (wow, that was fast!), but the "Here is the result" that follows it is still showing the old query and old results. This is probably on someone's "to do" list already, but I thought it was worth mentioning just in case ...

... and I finally got to continuing the lesson and I think the next example "... where we want to find Gene Hackman and the movies that he acted in with another person who also directed the movie." has a similar problem. I believe the anonymous node at the end of the exists() clause should reference the specific Movie node (m). None of the sample data is matched incorrectly in this case.

Working on it....