neo4j/neo4j-documentation

Query example error

KDean-Dolphin opened this issue · 1 comments

In "3.2.5.2. General operators", the query example for DISTINCT is shown as:

CREATE (a:Person { name: 'Anne', eyeColor: 'blue' }),(b:Person { name: 'Bill', eyeColor: 'brown' }),(c:Person { name: 'Carol', eyeColor: 'blue' })
WITH a, b, c
MATCH (p:Person)
RETURN DISTINCT p.eyeColor

Basically, the "WITH" operator isn't doing anything here and if there are other Person nodes in the database the result set is not what is expected. The query should be:

CREATE (a:Person { name: 'Anne', eyeColor: 'blue' }),(b:Person { name: 'Bill', eyeColor: 'red' }),(c:Person { name: 'Carol', eyeColor: 'blue' })
WITH [a, b, c] AS ps
UNWIND ps AS p
RETURN DISTINCT p.eyeColor

@KDean-Dolphin I have simplified the query with #106. The manual's example graphs will in the near future be completely re-worked so that the intention of the query is not conflated with the creation of data where not necessary. Thanks for raising.