3
votes

In my graph, I have more than one relationship between 2 nodes. For ex. A-[HAS_P]->B, A-[HAS_Q]->B and A-[HAS_R]->B. How do I exclude HAS_R but still display the pattern A-[]-B with the other two relationships HAS_P and HAS_Q? I tried this query but it shows all relationships and doesn't exclude HAS_R relationship.

MATCH x = (A)-[r*..4]-(B) 
WHERE NONE(r in relationships(x) WHERE type(r)="HAS_R") 
RETURN x
2

2 Answers

3
votes

By default the browser is configured to display all relationship between the returned node.

You can disable this feature by uncheck this checkbox :

Neo4j browser configuration

0
votes

Your query could be simplified, depending on the data model:

(1) If you only have this three relationship types (HAS_P, HAS_R and HAS_Q), you can specify the two that you allow:

MATCH x = (A)-[:HAS_P|HAS_Q*..4]-(B)
RETURN x

(2) If you might other relationship types (and more may appear in the future):

MATCH x = (A)-[*..4]-(B)
WHERE NONE(r in relationships(x) WHERE type(r) = 'HAS_R') 
RETURN x

Note: you do not have to specify the name (r) for the relationship in the MATCH part of the query.

Also, check @logisima's answer for dealing with the web browser UI.