1
votes

I am a newbie in Neo4j and I will appreciate some help...
I have the following simple graph http://console.neo4j.org/?id=colc1f

Basically I want to retrieve relations for specific node for example for node ID: 1
Imagine that except from FOLLOW,FRIEND there are more relation types but the only exception is with the FRIEND relations, because I only care about FRIEND relations which are incoming to the context node (1) and I want to retrieve all the relations in one query.

So the basic cypher query is:

start profile=node(1) 
match profile-[r:FRIEND|FOLLOW|..]-other 
return type(r),other

But how do I filter the FRIEND relations which are outgoing from the context profile in the same query?

Thanks.

1

1 Answers

3
votes

You can throw the extra validation into the where, and do something like:

 start profile=node(1) 
 match profile-[r:FRIEND|FOLLOW]-other 
 where profile-[:FRIEND]->other 
    or type(r) <> "FRIEND" 
return type(r),other

http://console.neo4j.org/r/dgas8o