title: cypher narrow search with same node property
body: <p>the question I have is here : <a href="https://stackoverflow.com/questions/49275603/cypher-how-get-relation-between-every-two-node-and-the-distance-from-start-node">cypher-how-get-relation-between-every-two-node-and-the-distance-from-start-node</a>, more detail here: 2 million companies, each of them must and only belong to a leading company，called group, so every node has properties: groupId and companyId; what's more, companies in different group may have relationship.  QUESTION: given a groupId and the leading company id, return all relations in this group and every node in the group's shortest distance to leading company.</p>
  
  <p>since the sql that anwser have big performance issue, especially the shortPath one, so my question is can we narrow down the search scope when use shortPath， only search nodes with same property?</p>
  
  <p>or are there other way to solve the original question?</p>
  
  <p>sorry since I am in China mainland, cannot reach the console.neo4j.com(even with VPN), so I put my sample here:</p>
  
  <pre><code>create (a :COMPANY {companyId:"a",groupId:"ag"}),
         (b:COMPANY  {companyId:"b",groupId:"ag"}),
         (c:COMPANY  {companyId:"c",groupId:"ag"}),
         (d:COMPANY {companyId:"d",groupId:"ag"}),
         (e:COMPANY  {companyId:"e",groupId:"eg"})
  create (a)-[:INVESTMENT]-&gt;(b),
         (b)-[:INVESTMENT]-&gt;(c),
         (c)-[:INVESTMENT]-&gt;(d),
         (a)-[:INVESTMENT]-&gt;(c),
         (d)-[:INVESTMENT]-&gt;(b),
         (c)-[:INVESTMENT]-&gt;(e) 
  return *
  </code></pre>
  
  <p>here the node <code>a,b,c,d</code> are same group and <code>a</code> is leading company,<code>e</code> are another group but has relationship with <code>c</code>. so I want get the node-node relation in <code>ag</code> group, for example: <code>a-b,a-c,b-c,c-d,d-b</code> and the shortest distance from <code>a</code> to group member, for example,return <code>dist.a=0,dist.b=1,dist.c=1,dist.d=2</code></p>