Reputation: 111
Let's say I have a match query which returns a list of nodes (oms), and next I match nodes (rs) which are related to (oms), but I only want them if the single node of (rs) has a relation to ALL or MORE of the list I returned earlier (oms). Here is what my query looks like:
MATCH (st:Route) WHERE id(st) = 0
MATCH (st)--(rs:RS)--(oms:OMS)
WITH st,rs, collect(oms) AS omsList
MATCH (ed:Route)--(rs2:RS)
WHERE ALL(x in omsList WHERE (rs2)--(x))
UNWIND omsList AS oms
RETURN *
And this is what my query gives:
But as explained from above, I do not want nodes 20 and 21 because they do not have a relation to ALL of the nodes returned from the list.
Note I start from node 0 which ends with the (oms) nodes 4 and 2. So I only want them if they have relations to BOTH 4 AND 2.
How would I query this the way I want to?
Upvotes: 2
Views: 939
Reputation: 16375
Seems to me that your query is right. I think your issue is related to a Neo4j Browser visualization feature called "Connect result nodes". When this feature is enabled, Neo4j browser will connect the resultant nodes in the graph visualization mode when a connection between these nodes exist.
To disable this behavior you should go to the section "Graph Visualization" of Neo4j Browser Settings and uncheck the option "Connect result nodes" as shown in the image below:
Upvotes: 2