Search code examples
cypheranormcypherredisgraph

RedisGraph - Combining multiple directives with MERGE


I am currently running the below query on Neo4J

match (p:Initial{state: 'Initial', name: 'Initial'}), (c:Encounter{code:'abcd', state: 'Encounter', name: 'Encounter1'})
merge (p)-[:raw {person_id:'1234', type:'Encounter', code:'abcd'}]->(c)

However I am unable to do the same query on RedisGraph. According to what I have found so far, Redis does not seem to support combining MERGEwith other directives

  1. Is there any workaround to this?
  2. Can the query be changed to allow it to execute the same functionality without the match statement?

Solution

  • The only option I see right now is to split this into two queries, The first one checks to see if p is connected to c:

    MATCH (p:Initial{state: 'Initial', name: 'Initial'})-[:raw {person_id:'1234', type:'Encounter', code:'abcd'}]->(c:Encounter{code:'abcd', state: 'Encounter', name: 'Encounter1'}) RETURN p,c
    

    If the above query returns empty issue a second query to form the relation:

    MATCH (p:Initial{state: 'Initial', name: 'Initial'})(c:Encounter{code:'abcd', state: 'Encounter', name: 'Encounter1'}) CREATE (p)-[:raw {person_id:'1234', type:'Encounter', code:'abcd'}]->(c)