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.

Cypher match and return distinct nodes according to a parameter

madiskou
Graph Buddy

Hello,
I have a simple query like this :

MATCH (n:application) RETURN n

and with a parameter 'app' in the node, so with this query for each application i have like 2 nodes with different ids but with the same parameter 'app'.

What i want is to get all applications nodes with distinct on 'app' param, in the case that i have two nodes i want one of them not the 2 returned.

Thank you,

1 REPLY 1

you can try the following. It will query for all Application nodes, groups them by n.app values, then return only one node for each distinct value of n.app

MATCH (n:application)
with n.app, collect(n) as nodes
return n.app, nodes[0]