Is there a way to get only the nodes and relationships that are present in the Cypher query and not other relationships between nodes?
We know that nodes can have many different types of relationships between them. During analysis though, we only want to look at a specific type of relationship. the rest is clutter. Using the movie database as an example, let's use the following query.
match (p:Person)-[:ACTED_IN]->(m:Movie)
where p.name='Tom Hanks'
return p, m;
In this query we get a nice graph of Tom Hanks and all the movies he acted in. However we also get the relationship [:DIRECTED]
for the movie "That Thing You Do" which is interesting but depending on what you are analyzing, it's a distraction. I only want to display the [:ACTED_IN]
relationship. Using the next query
match (p:Person)-[:ACTED_IN]->(m:Movie)<-[:DIRECTED]-(d:Person)
where p.name='Tom Hanks'
return p, m, d;
We get a nice view of the directors for each movie. Here though, the screen is cluttered with the [:KNOWS]
relationship causing a distraction.
I know several of the data visualization products can do this, but we are in a POC and we need to get the database in first. It will be a harder sell if I have to add in a data visualization tool as well. Harder but not an impossible sell.
Currently, I am using Neo4j 3.2 but will upgrade to 3.3 for actual demo shortly.
match (p:Person)-[a:ACTED_IN]->(m:Movie) where p.name='Tom Hanks' return p, a, m
and turn autocomplete off by going to the bottom of the settings menu and unticking Connect result nodes. – Gabor Szarnyas