cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Show nodes which have at least one relationship with specific labelled nodes

Hi !

I am currently trying to show via Neo4j Browser all nodes with a specific Label (Here named "Label1"), when each of them have at least one connection with 3 specific labelled nodes ("X","Y","Z"). I've tried the following query:

MATCH (a)-->(b)
where a:Label1
and size((a)-->(b)) >= 1
and b:X
and b:Y
and b:Z
RETURN a,b, size((a)-->(b)) AS count

However, it returns me everything instead of only nodes with these labels. Did I made something wrong here ?

I've also Tried to exclude nodes with labels I don't want to see, like:

and not b:LabelX

But they still appear.

Thank you 🙂

1 ACCEPTED SOLUTION

There is the answer coming from Stackoverflow website:

MATCH (a:Label1)
WHERE (a)-->(:X)
AND   (a)-->(:Y)
AND   (a)-->(:Z)
RETURN a

Link here: https://stackoverflow.com/questions/58025177/show-nodes-which-have-at-least-one-relationship-with-sp...

Thank you anyway

View solution in original post

4 REPLIES 4

In Neo4j Browser, you must turn off "connect result nodes" in settings on the left.

Elaine

Hum, now I have nothing returned... However I know that it should return something. Also, I've removed some labels on the filter, and I still have nothing once I turned off "connect result nodes"

count() is a value so the results are returned in tabular format only. If you were to not return count(), then you should be able to see the visualization of the graph with just what you asked to be returned. That is, you should return either paths or nodes and relationships.

Elaine

There is the answer coming from Stackoverflow website:

MATCH (a:Label1)
WHERE (a)-->(:X)
AND   (a)-->(:Y)
AND   (a)-->(:Z)
RETURN a

Link here: https://stackoverflow.com/questions/58025177/show-nodes-which-have-at-least-one-relationship-with-sp...

Thank you anyway