'Match One or the other condition

I'm trying to do something like this :

  • Flow must have a relationship with :
    • An Application OR
    • A Partner

My Flow must have one of these two relationships. I tried to something like this :

    MATCH (c:Flow)-[y:AppliFlux]-(d:Application)
    OPTIONAL MATCH (c)-[r:FlowPart]-(e:Partner)
    return c

But it doesn't return what i need. Thanks for your help



Solution 1:[1]

You can use a WHERE with conditions checking by the relationships existence:

MATCH (c:Flow)
WHERE (c)-[:AppliFlux]-(:Application)
OR (c)-[:FlowPart]-(:Partner)
RETURN c

[EDIT]

After some talk in the chat, the solution that best fits the requirements from the question is the following:

MATCH (a:Domain)-[r:AppliDom]-(b:Application)-[t:AppliFlux]-(c:Flo??w)-[y:AppliFlux]-(??d:??Application)-[u:Appl??iDom]-(e:Domain) 
RETURN {a:a,c:c,e:e} as elements 
UNION 
MATCH (c)-[r:FlowPart]-(e:Partner) 
RETURN {c:c} as elements

That is: the use of UNION returning projections.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1