surenyonjan
surenyonjan

Reputation: 2109

cypher not returning rows with multiple combined match statement

I ran two Cypher queries which gives me some result

Cypher 1:

neo4j-sh (?)$ MATCH (a: Answer { id: "answerID" })<-[:CHOSE]-(u: User) 
> RETURN count(u);                                                                     
+----------+
| count(u) |
+----------+
| 1        |
+----------+
1 row
19 ms

Cypher 2:

neo4j-sh (?)$ MATCH (q: Question)-[:ANSWER]->(a: Answer { id: "answerID" })
> RETURN count(q);
+----------+
| count(q) |
+----------+
| 1        |
+----------+
1 row
14 ms

But combining these two condition gives me zero results

neo4j-sh (?)$ MATCH (q: Question)-[:ANSWER]->(a: Answer { id: "answerID" })<-[:CHOSE]-(u: User)
> RETURN count(u);
+----------+
| count(u) |
+----------+
| 0        |
+----------+
1 row
31 ms

Is there anything wrong with this query? Help!

Upvotes: 0

Views: 211

Answers (1)

Stefan Armbruster
Stefan Armbruster

Reputation: 39915

Is it possible that you have to different Answer nodes with id="answerId" ? Check using:

MATCH (a:Answer{id:'answerID'}) return count(a)

If this gives a result > 1 it would prove my theory. In this case one of them would be connected to a Question and another one might be connected to a User.

Duplicated nodes can occur if e.g. you use non-granular MERGEs in LOAD CSV.

Upvotes: 1

Related Questions