I got something like that:
WITH a.id as `aId`, a.acRef as `acRef`
WITH b.id as bId, b.bcRef as `bcRef`
WHERE acRef=c.aRef and bcRef=c.bRef
RETURN aId, bId, c.id as `cId`
but ofcourse it doesn't work because I'm not passing aId and acRef from second subquery to main query. I can do that but then query would execute for really long time (no association between a and b nodes).
Is it possible to make Cypher query with independent subqueries?
Not really sure why you do relational-style joining in a graphdb
MATCH (a:A) with collect(a) as aNodes
MATCH (b:B) with collect(b) as bNodes
WHERE c.aRef IN [a IN aNodes | a.acRef] and c.bRef IN [b IN bNodes | b.bcRef]
RETURN c.id as `cId`, head(a IN aNodes WHERE c.aRef = a.acRef | a.id ]) as aId,
head(b IN bNodes WHERE c.bRef = b.bcRef | a.id ]) as bId
MATCH (c:C) WHERE a.acRef=c.aRef
MATCH (b:B) WHERE b.bcRef =c.bRef
RETURN a.id as aId, b.id as bId, c.id as cId
depending on the query you should have indexes on the acRef, bcRef and aRef, bRef fields.
Thank you for quick response. I know that I shouldn't join like that
I just wondered if I could make temporary sets of nodes to use on later part of the query (like WITH in postgresql).