cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Count unique string after splitting

hi
i have 3 nodes with property name education
(node1)["education"] = "school1::uni1"
(node2)["education"] = "school3::uni1"
(node3)["education"] = "school3"

i want to count the unique string after splitting by delimiter "::"
so the final result would be like this
school1 1
school3 2
uni1 3

thank you for the support

4 REPLIES 4

There are a few ways to do this.

The easiest way is probably to UNWIND the collections from the split, then collect the distinct results:

match (n:Node)
with n, split(n.education, '::') as eduList
unwind eduList as edu
return collect(distinct edu) as edu

thank you for your help
but this will return all the string in one array
all i really want to achieve this
unique string and its count

once again thanks you

Okay, I missed that part. In that case it's enough to UNWIND the list from the split, then get the count of each entry. This won't collect the results, but it should work for you.

match (n:Node)
with n, split(n.education, '::') as eduList
unwind eduList as edu
return edu, count(edu) as count

It really helped me as well....