my use case is the following: - a principal in a group has access to all other principals in a group => therefore I need to go one level up to find the other principals in the group - additionally: if there is another group as principal in a group (UserGroup 1 is in UserGroup 2) , then the principal also has access to the principals of the sub-group (User 3 has access to User 1 and User 2 which are in sub-group UserGroup 1) => that is the second part in the MATCH clause
Your idea looks like it is working: MATCH (principals)-[:IS_MEMBER_OF*0..1]-> Thanks. Nevertheless, maybe Peter has another/better idea :-) Am 02.11.2011 11:34, schrieb Michael Hunger: > If I understand you correctly, then your start nodes (aka "UserGroup 2") > would be dangling as there is no > relationship IS_MEMBER_OF starting from this group. > > so your start nodes are connected by an optional relationship, so everything > also hanging on this optional relationship is also optional. > > What would you expect when starting with "UserGroup 2" ? > > Probably it is mixing two use-cases ? > > First one starting from the leaf-nodes like users >> MATCH (principals)-[:IS_MEMBER_OF]->()<-[:IS_MEMBER_OF*0..]-(n) > and a second one starting from higher level nodes like groups. >> MATCH (principals)<-[:IS_MEMBER_OF*0..]-(n) > So that is a different place for the starting points in the match. > > Perhaps something like this could work: >> MATCH (principals)-[:IS_MEMBER_OF*0..1]->()<-[:IS_MEMBER_OF*0..]-(n) > > But perhaps better when Peter chimes in later today as he spent a lot of time > applying Cypher to ACL scenarios. > > Michael > > Am 02.11.2011 um 11:18 schrieb D. Frej: > >> I though that this is what I used with >> MATCH (principals)-[?:IS_MEMBER_OF]-> >> >> When I turn it into >> MATCH (principals)-[?]->()<-[:IS_MEMBER_OF*0..]-(n) >> RETURN n >> >> Nothing at all is returned >> >> >> >> >> Am 02.11.2011 11:05, schrieb Jacob Hansson: >>> On Wed, Nov 2, 2011 at 11:01 AM, D. Frej<[email protected]> wrote: >>> >>>> Hi, >>>> >>>> I have a very simply graph: >>>> >>>> UserGroup 2<-[:IS_MEMBER_OF]- UserGroup 1, User 3 >>>> UserGroup 1<-[:IS_MEMBER_OF]- User 1, User 2 >>>> >>>> I want to find all nodes that are on the same level or on a level below >>>> the starting point. Using >>>> >>>> START principals=node:nodes(NAME='User 3') >>>> MATCH (principals)-[?:IS_MEMBER_OF]->()<-[:IS_MEMBER_OF*0..]-(n)" >>>> RETURN n >>>> >>>> I first go one level up and then determine all nodes below this level. >>>> However, it is not working if I change the start to >>>> >>>> START principals=node:nodes(NAME='UserGroup 2') >>>> (because there is no IS_MEMBER_OF relationship to go up). >>>> >>>> Is there a way to ommit this condition if it is not available? To make >>>> it somehow optional? >>>> >>> You could use an optional relationship here. See: >>> >>> http://docs.neo4j.org/chunked/snapshot/query-match.html#match-optional-relationship >>> >>> Note that this is the snapshot version of the documentation, you will want >>> to look at the documentation for the version of neo4j you are using to make >>> sure that this syntax is supported. >>> >>> >>>> Thanks, >>>> >>>> - Didi >>>> _______________________________________________ >>>> Neo4j mailing list >>>> [email protected] >>>> https://lists.neo4j.org/mailman/listinfo/user >>>> >>> >> _______________________________________________ >> Neo4j mailing list >> [email protected] >> https://lists.neo4j.org/mailman/listinfo/user > _______________________________________________ > Neo4j mailing list > [email protected] > https://lists.neo4j.org/mailman/listinfo/user > _______________________________________________ Neo4j mailing list [email protected] https://lists.neo4j.org/mailman/listinfo/user

