cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! Site migration is underway. Expect disruption to service on Thursday, Feb. 9!

Browser displaying all relationships between two nodes, even when filtered out

Browser displaying all relationships between two nodes, even when filtered.

This code shows the problem, if you have the time to run it I'd be very grateful.

merge (:Entity { name: 'Zara' } );
merge (:Age {value: '30-34'});
merge (:Gender {value: 'Female'});
merge (:Location {value: 'Johannesburg'});

match (e:Entity     { name:  'Zara'})
match (a:Age        { value: '30-34'})
match (g:Gender     { value: 'Female'})
match (l:Location   { value: 'Johannesburg'})
merge (e)-[:Question {Label: 'T1'}]->(a)
merge (e)-[:Question {Label: 'T1'}]->(g)
merge (e)-[:Question {Label: 'T1'}]->(l);

match (e:Entity     { name:  'Zara'})
match (a:Age        { value: '30-34'})
match (g:Gender     { value: 'Female'})
match (l:Location   { value: 'Johannesburg'})
merge (e)-[:Question {Label: 'T2'}]->(a)
merge (e)-[:Question {Label: 'T2'}]->(g)
merge (e)-[:Question {Label: 'T2'}]->(l);

MATCH p = (e:Entity)-[q:Question]->() where q.Label = 'T1' RETURN p

What I'd like is a single relationship displayed between the central "Entity" node and each of the surrounding nodes. What I'm getting is both the T1 and T2 relationships displayed....

Hopefully it will be a common error or design issue that people can have a laugh at as you point out my neo inexperience. Seriously, comments are very welcome.

1 ACCEPTED SOLUTION

glilienfield
Ninja
Ninja

There is a setting in Neo4j Browser that when set shows all the relationships between the returned nodes. You can disable it to get what you want. The setting is "Connect result nodes."

3X_4_a_4a7d86eb8e69d482abb78815399137a4986b2cc2.png

View solution in original post

5 REPLIES 5

glilienfield
Ninja
Ninja

There is a setting in Neo4j Browser that when set shows all the relationships between the returned nodes. You can disable it to get what you want. The setting is "Connect result nodes."

3X_4_a_4a7d86eb8e69d482abb78815399137a4986b2cc2.png

Hello Gary,

Thank you - that does exactly what I wanted.

It is best practise not to do this?

It depends on your needs.  I find both settings useful. Depends what I am doing.  I leave it checked when I want to visualize data, as I only need to search fir nodes and the relationships are shown.  I leave it unchecked when I want to see only the result of queries.  In this case you need to return both nodes and relationships to visualize the relationships. 

glilienfield
Ninja
Ninja

No worries. I had the same issue when starting.

It depends on your requirements. I like it checked most of the time, since I can query for nodes and it shows me all the relationships too. It helps visualize. I like it unchecked when I am querying for specific patterns, as you are doing.

Sounds good, thx again