Display only a specific relationship type in a Neo4j Browser query
Asked Answered
B

4

13

I have a simple Neo4j graph database that I created while trying to model something for a new application. When I run the following query, I get the nodes that I am expecting, but I also get more relationships than I bargained for:

MATCH (o:Office)-[r:REPORTS_VARIABLE_TO]->() 
RETURN o,r

This is what the results look like:

Graph Query Results

Since I specifically requested things that match with [:REPORTS_VARIABLE_TO] I expected to see only that relationship in the results. What I see, though, is all relationships that exist between any matching nodes (as you can see on the bottom of the image).

Is there a way to filter out those relationships that are not of the type I'm looking for?

Byram answered 6/7, 2016 at 13:9 Comment(0)
B
9

So, as Nicole White was kind enough to point out, the answer is to turn off the "auto-complete" toggle in the Neo4j visualizer (bottom right hand corner, outlined in red in the image below).

This causes the app to no longer display all of the relationships between displayed/selected nodes and to only show the relationships and nodes named in the query, as demonstrated below:

enter image description here

Byram answered 6/7, 2016 at 15:42 Comment(0)
W
10

For the newest versions (e.g 3.2, 3.3) the "auto-complete" toggle has been moved to the browser settings and its new name is "Connected all results". If it is checked, it connects nodes with all of their relationships. Otherwise, you only see relationships which meet the filtering criteria.

Wanting answered 22/2, 2018 at 20:58 Comment(4)
As of 3.2.5, the option is now "Connect Result Nodes". I think the behavior is different though.Femme
I don't know about the previous behavior, but currently if you uncheck this option, none of the relationships appear...not even the ones your specify. Perhaps there is a specific (and undocumented) way they need to be specified in order to show up in this case.Richards
Working for me with RETURN node, rHydrated
@AaronBramson I found with the 'Connect result nodes' unchecked, I now have to return the relationship node.Irritative
B
9

So, as Nicole White was kind enough to point out, the answer is to turn off the "auto-complete" toggle in the Neo4j visualizer (bottom right hand corner, outlined in red in the image below).

This causes the app to no longer display all of the relationships between displayed/selected nodes and to only show the relationships and nodes named in the query, as demonstrated below:

enter image description here

Byram answered 6/7, 2016 at 15:42 Comment(0)
D
4

I'm pretty sure this is just a feature of the visualisation in the back-end that will display all relationships between any two nodes on the screen (note that it also displays the destination nodes even though you haven't asked for them in the return statement).

If you look at the raw query results you'll only get the relationship types you specify.

So, to put it simply: your query is perfectly valid and correct; this is just the Neo4j admin tools playing a trick on you.

Dragelin answered 6/7, 2016 at 13:13 Comment(2)
The answer though is to toggle off "autocomplete" in the browser. You'll see it in the bottom right of the window.Mehta
I am using version 3.0.1 of the neo4j browser and there is no auto-complete toggle. I have looked at all of the settings and can't find how to turn this off.Lezlielg
T
4

Using Neo4j Desktop 1.3.8 and the Neo4j Browser, you need to uncheck the setting "Connect result nodes".

  1. Open the Neo4j Browser for your database.
  2. Click "Browser Settings" gear icon.
  3. Scroll to bottom and uncheck "Connect result nodes"
  4. Re-run your query in the browser

Neo4j Desktop 1.3.8 Settings

Therefore answered 22/10, 2020 at 19:32 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.