I need to perform a Neo4J Cypher query where I exclude the nodes from the result that are connected to a specific node.
I'm using that query below, but it's very slow (several seconds).
What I do below is to first get the node (of the Context type), which the other nodes should not be connected to.
Then I make the next query, finding the nodes, created by the same user but in another context "help" and exclude those of them that are also connected to the "private" context.
MATCH (u:User{uid:'6dbe5450-852d-11e4-9c48-b552fc8c2b90'}),
(ctxa:Context{name:"private"}), ctxa-[:BY]->u
WITH ctxa,u MATCH (s:Statement), (ctx:Context{name:"help"}), ctx-[:BY]->u,
s-[:IN]->ctx, s-[:BY]->u
WHERE NOT s-[:IN]->ctxa
RETURN DISTINCT s.uid ORDER BY s.timestamp DESC;
Anyone has a better idea?
UPDATE: I also tried this:
MATCH (u:User{uid:'b9745f70-a13f-11e3-98c5-476729c16049'}), (s:Statement),
(ctx:Context{name:"private"}), ctx-[:BY]->u, s-[:IN]->ctx, s-[:BY]->u
WITH s AS sta, u MATCH (s:Statement), (ctx:Context{name:"help"}),
ctx-[:BY]->u, s-[:IN]->ctx, s-[rel:BY]->u WHERE s <> sta RETURN DISTINCT s;