title: Neo4j directed path through multiple relationships with property filter
body: <p>Being new to Cypher and Neo4j, I am having trouble constructing my query for my use-case. I am building a simple ACL (access control list) and am looking for a path through permission relationships an up a hierarchy as well. A picture may better explain it:</p>
  
  <p><img src="https://i.stack.imgur.com/cC8KN.png" alt="enter image description here"></p>
  
  <pre><code>Key:
      Users -&gt; Blue
      Groups -&gt; Yellow, Green
      Resource Tree -&gt; Red
  </code></pre>
  
  <p>Now I want to see if a path exists from Bob to the <em>eVar 33</em> resource where Bob has <em>update</em> access. Because there is a direct path, I can get what I am looking for by running</p>
  
  <pre><code>MATCH p =(usr:Usr)-[:AXO {update: true}]-&gt;(aco:ACO)
  WHERE usr.name = 'Bob' AND aco.name = 'eVar 33'
  RETURN p
  </code></pre>
  
  <p>But now, Bob is also a member of the <em>Media Mgmt</em> group which grants him <em>read</em> access to the <em>Conversion</em> resource. And because <em>Conversion</em> is further up the resource tree than <em>eVar 33</em>, <em>eVar 33</em> should inherit this permission. But when I run the same query looking for <code>{read: true}</code> instead, no path is found. I know this is because I am not allowing traversal through the <code>:IN</code> and <code>:HAS</code> relationships, but how can I do this?</p>
  
  <p>I have tried:</p>
  
  <pre><code>MATCH p =(usr:Usr)-[:IN|:HAS|:AXO {read: true}]-&gt;(aco:ACO)
  WHERE usr.name = 'Bob' AND aco.name = 'eVar 33'
  RETURN p
  </code></pre>
  
  <p>thinking this would allow those relationships to be traversed, but it still does not find a path (because I am not allowing more than a depth of 1?).</p>
  
  <p>So here are my needs:</p>
  
  <ul>
  <li>Unknown depth of path</li>
  <li>Any path(s) I get back are fine (all I really care about is "Is there a path or not?")</li>
  <li>Must be able to get from a user to a resource AND when an AXO relationship is being followed it must match a property filter.</li>
  <li>Must follow the directed graph (i.g. Bob has no permissions for <em>Analytics</em>)</li>
  </ul>
  
  <p><em>And no, I do not work for Nike. Just an example use-case here :)</em></p>