lowatt
lowatt

Reputation: 363

neo4j node query dismatch

I'm using neo4j 1.9.4.

Please consider the following two queries :

  1. start z=node(*) where z._type! = 'aaa' return count(z);

  2. start z=node(*) match z-[r?]-() where z._type! = 'aaa' return count(z), count(r);

Shouldn't the result of "count(z)" be the same for both of the two queries?

But I got a result of 2 much larger than the result of 1.

Is this a neo4j bug or is there something wrong with the queries?

Upvotes: 0

Views: 36

Answers (1)

ulkas
ulkas

Reputation: 5918

no, because when there are nodes with several relationships, z-[r?]-() will return several results and thus when returning count(z) you will have duplicate values.

try to return count(DISTINCT z)

Upvotes: 2

Related Questions