title: Cypher directionless query not returning all expected paths
body: <p>I have a cypher query that starts from a machine node, and tries to find nodes related to it using any of the relationship types I've specified:</p>
  
  <pre><code>match p1=(n:machine)-[:REL1|:REL2|:REL3|:PERSONAL_PHONE|:MACHINE|:ADDRESS*]-(n2)
  where n.machine="112943691278177215"
  optional match p2=(n2)-[*]-&gt;()
  return p1,p2
  limit 300
  </code></pre>
  
  <p>The <code>optional match</code> clause is my attempt to traverse outwards in my model from each of the nodes found in <code>p1</code>. The below screenshot shows the part of the results I'm having issues with:</p>
  
  <p><a href="https://i.stack.imgur.com/qBnVk.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qBnVk.png" alt="initial results"></a></p>
  
  <p>You can see from the starting machine node, it finds a personal_phone node via two app nodes related to the machine.  For clarification, this part of the model is designed like so:</p>
  
  <p><a href="https://i.stack.imgur.com/g3Hym.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/g3Hym.png" alt="model"></a></p>
  
  <p>So it <em>appeared</em> to be working until I realized that certain paths were somehow being left out of the results.  If I run a second query showing me all apps related to that particular personal_phone node, I get the following:</p>
  
  <pre><code>match p1=(n:personal_phone)&lt;-[*]-(n2)
  where n.personal_phone="(xxx) xxx-xxxx"
  return p1
  limit 100
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/L9pic.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/L9pic.png" alt="personal_phone"></a></p>
  
  <p>The two apps I have segmented out, are the two apps shown in the earlier image.  </p>
  
  <p>So why doesn't my original query show the other 7 apps related to the personal_phone?</p>
  
  <p><strong>EDIT</strong> : Despite the overly broad optional match combined with the <code>limit 300</code> statement, the returned results show only 52 nodes and 154 rels.  This is because the paths following relationships with an outward direction are going to stop very quickly.  I could have put a max 2 on it but was being lazy.</p>
  
  <p><strong>EDIT 2</strong>:  The query I finally came up with to give me what I want is this:</p>
  
  <pre><code>match p1=(m:machine)&lt;-[:MACHINE]-(a:app)
  where m.machine="112943691278177215"
  optional match p2=(a:app)-[:REL1|:REL2|:REL3|:PERSONAL_PHONE|:MACHINE|:ADDRESS*0..3]-(n)
  where a&lt;&gt;n and a&lt;&gt;m and m&lt;&gt;n
  optional match p3=(n)-[r*]-&gt;(n2)
  where n2&lt;&gt;n
  return distinct n, r, n2 
  </code></pre>
  
  <p>This returns 74 nodes and 220 rels which seems to be the correct result (387 rows).  So it seems like my incredibly inefficient query was the reason the graph was being truncated.  Not only were the nodes being traversed many times, but the paths being returned contained duplicate information which consumed the limited rows available for return.  I guess my new questions are: </p>
  
  <ol>
  <li>When following multiple hops, should I always explicitly make sure the same nodes aren't traversed via <code>where</code> clauses?</li>
  <li>If I was to <code>return p3</code> instead, it returns 1941 rows to display 74 nodes and 220 rels.  There seems to be a lot of duplication present. Is it typically better to use return distinct (like I have above) or is there a way to easily dedupe the nodes and relationships within a path?</li>
  </ol>