1
votes

In Neo4j I have the following database:

node1-[:link {prop: a}]->node2-[:link {prop: a}]->node3-[:link {prop: a}]->node4
node1-[:link {prop: b}]->node2-[:link {prop: b}]->node3
node1-[:link {prop: c}]->node2-[:link {prop: c}]->node3

I would like to return node1, node2, node3, node4 with only the relationships that have the property {prop: a}. the cypher I have tried as as follows:

MATCH (n1)-[r:link {prop: 'a'}]-(n2)
RETURN n1, r, n2

The problem is that it also returns me all the relationships in between the nodes that are not {prop: a}. How do I return only the relationships with said property?

1

1 Answers

2
votes

I'm assuming you're looking at the graph results view.

By default the browser will show all relationships between returned nodes, even if they aren't returned by the query. You can disable this in the Browser Settings menu (gear icon in the lower left), scroll to the bottom, and uncheck Connect result nodes. Rerun your query and the browser view should reflect your expected results.