Search code examples
if-statementneo4jcypher

testing value in NEO4j


I'm trying to get around IF queries in NEO4J.

Something like (if I could use IF):

MATCH (n:person)<-[r:aetei]-(m:person)    
IF m.ai >= 2
RETURN n, m, r

with aetei being a relationship between persons, and ai an attribute (obviously).

I tried some queries with foreach, but without results as I don't understand what to put after the | and how to get into the return. I've seen some examples with queries in the RETURN ... is that possible ? greetings

I tried several solutions like FOREACH or CASE, but nothing worked. I guess I'm too fresh on NEO4J to really get what 'im doing. Should i install apoc ?


Solution

  • It looks like you are looking for WHERE:

    MATCH (n:person)<-[r:aetei]-(m:person)
    WHERE m.ai >= 2 
    RETURN n, m, r