RedisGraph / redisgraph-py

RedisGraph python client
https://redisgraph.io
BSD 3-Clause "New" or "Revised" License
189 stars 49 forks source link

Missing MERGE - ON CREATE SET, ON MATCH SET #120

Closed gomesian closed 3 years ago

gomesian commented 3 years ago

Love the Python library, but couldn't find arg options for using MERGE with ON CREATE SET, ON MATCH SET functions.

https://oss.redislabs.com/redisgraph/commands/#merge

Seams to be be the best way to Bulk update.. Any plans to add? Or did I miss it somewhere...

eg. MERGE (p:Person {name: 'Michael'}) ON CREATE SET p.created = 'timestamp', p.status = 'created', p.toreplace = 'replaceme' ON MATCH SET p.lastupdated = 'timestamp2', p.status = 'updated', p.toreplace = 'replace'

AvitalFineRedis commented 3 years ago

@gomesian Try to use it in the query string.

I tried to run

query = """MATCH (movie:Movie { name: 'Wall Street' }) 
    MERGE (person {name: 'Charlie Sheen'})-[:ACTED_IN]->(movie) 
    ON MATCH SET person.first_role = movie.name"""

result = redis_graph.query(query)
result.pretty_print()

and it worked :)