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.

Counting memberships but only conditional displaying

Hi all,

I'm struggling with a certain question I want answered:

The first part of my query is the following (it's a Bloodhound context):
"Give me all the domain admins that have "AMD_" as part of their username, as those are the human DA's, and show me all their first order group memberships." I translated this to:

MATCH (u:User)-[:MemberOf*1]->(g:Group {name:'DOMAIN ADMINS@FOO.LOCAL'}) 
WHERE u.name STARTS WITH "ADM_" 
WITH u MATCH p=(u)-[:MemberOf*1]->(n:Group) return p

As one can imagine, this gets ugly fast. With 20 admins at the moment, and 20-50 memberships each. Graphically unusable. What I now would like is to show only those groups that a subset of the "ADM_"'s is member of. (or be able to show only those groups that less than x "ADM_"'s are member of, to make it a bit more generic) So basically remove any node where:

  • The number of incoming "member of" connections is equal to the count of the number of "ADM_"'s OR
  • All "AMD_'s" are member of a particular group.

Maybe a more generic description of the problem would be:
"Show me a graph of group memberships proper subsets (A⊂B) of a given set of nodes are member of."

I think the first approach would be easier, but I don't know how to count these incoming memberof connections.

Looking forward to your help.

1 REPLY 1

ameyasoft
Graph Maven
Assuming the 'Group' node has a property 'member' that stores the DA's name

MATCH (g:Group)
where g.member STARTS WITH("AMD_") 
Return g
Nodes 2022
Nodes
NODES 2022, Neo4j Online Education Summit

All the sessions of the conference are now available online