I am trying to get distict property values on a list of nodes.
The property value is an array in graph. Example:
node1.color = [red]
node2.color=[red]
node3.color=[green]
node4.color=[yellow]
node5.color=[red]
My cypher query:
START n=node:index(type="sometype")
RETURN distinct n.color,count(*)
it returns
[red]
[red]
[green]
[yellow]
[red]
Shouldn't it just return 3 unique colors?
if not how do I access just the first element of an array property value in
the RETURN statement (ex: RETURN distinct n.color[0]? ) ?
I am using Neo 1.6M03.
Thanks in advance,
John
_______________________________________________
NOTICE: THIS MAILING LIST IS BEING SWITCHED TO GOOGLE GROUPS, please register and consider posting at https://groups.google.com/forum/#!forum/neo4j
Neo4j mailing list
Us...@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user
> Hello,
>
> I am trying to get distict property values on a list of nodes.
> The property value is an array in graph. Example:
> node1.color = [red]
> node2.color=[red]
> node3.color=[green]
> node4.color=[yellow]
> node5.color=[red]
>
> My cypher query:
> START n=node:index(type="sometype")
> RETURN distinct n.color,count(*)
>
> it returns
> [red]
> [red]
> [green]
> [yellow]
> [red]
>
> Shouldn't it just return 3 unique colors?
>
This is not what happens when I try it here:
- neo4j-sh (0)$ start n=node(0,1,2,3,4) return distinct n.color, count(*)
- ==> +---------------------+
- ==> | n.color | count(*) |
- ==> +---------------------+
- ==> | "red" | 3 |
- ==> | "green" | 1 |
- ==> | "yellow" | 1 |
- ==> +---------------------+
- ==> 3 rows, 3 ms
How are you running your tests? How are you inserting data?
Andrés
This is my output:
neo4j-sh (0)$ START n=node:fulltextIndex(type="person") RETURN distinct
n.color?,count(*)
==> +-----------------------+
==> | n.color | count(*) |
==> +-----------------------+
==> | ["red"] | 1 |
==> | ["green"] | 1 |
==> | ["green"] | 1 |
==> | ["amber"] | 1 |
==> | ["red"] | 1 |
==> | ["red"] | 1 |
==> | ["red"] | 1 |
==> | ["green"] | 1 |
==> | ["amber"] | 1 |
==> | ["amber"] | 1 |
==> | ["green"] | 1 |
==> | ["green"] | 1 |
==> | ["green"] | 1 |
==> | ["red"] | 1 |
==> | ["red"] | 1 |
==> | ["green"] | 1 |
==> | ["amber"] | 1 |
==> | ["green"] | 1 |
> That's strange.
> Did you load the property values as an array or just as string values?
> Your output values show "red" where as mine ["red"].
>
Yeah, sorry. Didn't catch the array value part. You have found a bug!
https://github.com/neo4j/community/issues/193
Thanks so much for reporting this.
I see that this issue has been fixed.