I'm evaluating RedisGraph and I'm trying to replicate a result I have in Neo4j.
Graph and query are from my other question, I'm trying to achieve the same result: the path f1 <- (friend) m2 <- (sibling) b3 <- (coworker) d4
(and none of the p*
nodes)
Nodes:
CREATE (a:temporary {name: 'm2'});
CREATE (a:temporary {name: 'f1'});
CREATE (a:temporary {name: 'b3'});
CREATE (a:temporary {name: 'd4'});
CREATE (a:temporary {name: 'p5'});
CREATE (a:temporary {name: 'p6'});
CREATE (a:temporary {name: 'p7'});
CREATE (a:temporary {name: 'k1'});
CREATE (a:temporary {name: 'k2'});
and relations:
MATCH (a) WHERE a.name = 'b3' MATCH (b) where b.name = 'm2' CREATE (a)-[:KNOWS {type: 'sibling'}]->(b);
MATCH (a) WHERE a.name = 'm2' MATCH (b) where b.name = 'f1' CREATE (a)-[:KNOWS {type: 'friend'}]->(b);
MATCH (a) WHERE a.name = 'd4' MATCH (b) where b.name = 'b3' CREATE (a)-[:KNOWS {type: 'coworker'}]->(b);
MATCH (a) WHERE a.name = 'p7' MATCH (b) where b.name = 'p6' CREATE (a)-[:KNOWS {type: 'friend'}]->(b);
MATCH (a) WHERE a.name = 'p6' MATCH (b) where b.name = 'p5' CREATE (a)-[:KNOWS {type: 'coworker'}]->(b);
MATCH (a) WHERE a.name = 'k1' MATCH (b) where b.name = 'b3' CREATE (a)-[:HAS]->(b);
MATCH (a) WHERE a.name = 'k1' MATCH (b) where b.name = 'd4' CREATE (a)-[:HAS]->(b);
MATCH (a) WHERE a.name = 'k1' MATCH (b) where b.name = 'm2' CREATE (a)-[:HAS]->(b);
MATCH (a) WHERE a.name = 'k1' MATCH (b) where b.name = 'f1' CREATE (a)-[:HAS]->(b);
MATCH (a) WHERE a.name = 'k2' MATCH (b) where b.name = 'p5' CREATE (a)-[:HAS]->(b);
MATCH (a) WHERE a.name = 'k2' MATCH (b) where b.name = 'p7' CREATE (a)-[:HAS]->(b);
MATCH (a) WHERE a.name = 'k2' MATCH (b) where b.name = 'p6' CREATE (a)-[:HAS]->(b);
The original Cypher query:
match p=(a:temporary)-[:KNOWS*0..]->(b)
where not ()-[:KNOWS]->(a) and not (b)-[:KNOWS]->()
and exists { match (k)-[:HAS]->(a) where k.name='k1' }
return p
Gives the following error, about the subpath in the EXISTS
:
Invalid input '(': expected ':', ',' or '}' line: 1, column: 112, offset: 111 errCtx: ... (b)-[:KNOWS]->() and exists { match (k)-[:HAS]->(a) where k.name='k1' } r... errCtxOffset: 40
I've rewritten it like this (with an additional MATCH
clause: is this equivalent to the above?
GRAPH.QUERY test "match p=(a:temporary)-[:KNOWS*0..]->(b) where not ()-[:KNOWS]->(a) and not (b)-[:KNOWS]->() with a, p match (k)-[:HAS]->(a) where k.name='k1' return p"