I've been struggling to solve this cypher query, if possible at all.
I want to return final nodes (finalNode) from my cypher query. And there are 2 ways one can find final nodes in db:
startNode <-[:r1]-finalNode (when finalNode is directly connected to startNode) ...and... startNode -[:r2*]->middleNode-[:r3]->finalNode (when finalNode is connected to middleNode, and this one is connected directly to startNode or to "parent" middleNode)
Both of these queries return finalNodes correctly, but I dunno how to connect them together for purpose of returning final nodes regardless in which way they are connected to start node.
I tried connecting tha match portion with comma, but it doesn't work :
> I've been struggling to solve this cypher query, if possible at all.
> I want to return final nodes (finalNode) from my cypher query. And there > are 2 ways one can find final nodes in db:
> startNode <-[:r1]-finalNode > (when finalNode is directly connected to startNode) > ...and... > startNode -[:r2*]->middleNode-[:r3]->finalNode > (when finalNode is connected to middleNode, and this one is connected > directly to startNode or to "parent" middleNode)
> Both of these queries return finalNodes correctly, but I dunno how to > connect them together for purpose of returning final nodes regardless in > which way they are connected to start node.
> I tried connecting tha match portion with comma, but it doesn't work :
From Neo4j docs example, my problem is that I want for node (3) (Anders) to find out all the poeple that he KNOWS, or he BLOCKS.
I'm very close to answer, the problem is that nodes are not distinct, so I have duplicates: start a=node(3) match x1-[?:KNOWS]-a-[?:BLOCKS]->x2 return collect([x1,x2]) Here is a link to try it out: http://console.neo4j.org/r/c7ime2 The result should contain 3 nodes, but it returns duplicate, so I have 4.
I have hoped initially that simplier query would be enough, but it doesn't return correct nodes (only 1): start a=node(3) match a-[?:KNOWS]-x<-[?:BLOCKS]-a return x
On Friday, July 27, 2012 9:05:26 AM UTC+2, vmarcinko wrote:
> Hello,
> I've been struggling to solve this cypher query, if possible at all.
> I want to return final nodes (finalNode) from my cypher query. And there > are 2 ways one can find final nodes in db:
> startNode <-[:r1]-finalNode > (when finalNode is directly connected to startNode) > ...and... > startNode -[:r2*]->middleNode-[:r3]->finalNode > (when finalNode is connected to middleNode, and this one is connected > directly to startNode or to "parent" middleNode)
> Both of these queries return finalNodes correctly, but I dunno how to > connect them together for purpose of returning final nodes regardless in > which way they are connected to start node.
> I tried connecting tha match portion with comma, but it doesn't work :
Am Samstag, 28. Juli 2012 08:19:28 UTC+2 schrieb vmarcinko:
> Hi again,
> First of all, thanx.
> From Neo4j docs example, my problem is that I want for node (3) (Anders) > to find out all the poeple that he KNOWS, or he BLOCKS.
> I'm very close to answer, the problem is that nodes are not distinct, so I > have duplicates: > start a=node(3) match x1-[?:KNOWS]-a-[?:BLOCKS]->x2 return collect([x1,x2]) > Here is a link to try it out: > http://console.neo4j.org/r/c7ime2 > The result should contain 3 nodes, but it returns duplicate, so I have 4.
The problem is that collect does not flatten nested collections. If it did, we could use distinct to filter out duplicates.
> I have hoped initially that simplier query would be enough, but it doesn't > return correct nodes (only 1): > start a=node(3) match a-[?:KNOWS]-x<-[?:BLOCKS]-a return x
This only returns results if both ends refer to the very same node.
> On Friday, July 27, 2012 9:05:26 AM UTC+2, vmarcinko wrote:
>> Hello,
>> I've been struggling to solve this cypher query, if possible at all.
>> I want to return final nodes (finalNode) from my cypher query. And there >> are 2 ways one can find final nodes in db:
>> startNode <-[:r1]-finalNode >> (when finalNode is directly connected to startNode) >> ...and... >> startNode -[:r2*]->middleNode-[:r3]->finalNode >> (when finalNode is connected to middleNode, and this one is connected >> directly to startNode or to "parent" middleNode)
>> Both of these queries return finalNodes correctly, but I dunno how to >> connect them together for purpose of returning final nodes regardless in >> which way they are connected to start node.
>> I tried connecting tha match portion with comma, but it doesn't work :