2

I am new to Neo4j and I have some trouble filtering out relationships in a return statement. I created two nodes and 3 instances of the same relationship between these two nodes that differ only in the value of the properties:

create (p:person {name:'batman'})
create (p:person {name:'superman'})

match (p1:person {name:'batman'}),(p2:person{name:'superman'}) create (p1)-  [h:HATES {intensity: 1}]->(p2)
match (p1:person {name:'batman'}),(p2:person{name:'superman'}) create (p1)-  [h:HATES {intensity: 2}]->(p2)
match (p1:person {name:'batman'}),(p2:person{name:'superman'}) create (p1)-  [h:HATES {intensity: 3}]->(p2)

When I try to visualise only one of those relationships (eg: intensity=2) with this code:

match (a: person)-[h:HATES]->(b: person) where h.intensity=2  return  a,h,b

all 3 relationships are plotted:

all relationships

Whereas by looking at the data only the filtered relationship is returned "a" "h" "b"

{"name":"batman"}   {"intensity":2} {"name":"superman"}

Does anyone know how to plot only the corresponding relationship?

Bruno Peres
  • 15,845
  • 5
  • 53
  • 89

1 Answers1

5

This is the default behavior of the Neo4j browser. If you are using Neo4j 3.2 go to "Browser settings" and uncheck the option "Connect result nodes".

Browser settings

After it the result showld be:

Result

If you are using a older version of Neo4j you should toggle the option highlighted in the image below:

Older versions

Bruno Peres
  • 15,845
  • 5
  • 53
  • 89
  • 1
    I wasted so much time thinking there was something wrong with my Cypher and it was actually a hidden thing from the visualizer, argh!! – Reuel Ribeiro Jul 27 '21 at 21:03