Imagine that two nodes, (:USER {name: "John"})
and (:AGE {name: "28"})
, exist. Now, the following query is ok with Neo4j
MATCH (u:USER {name: "John"})
MATCH (a:AGE {name: "28"})
MERGE (u)-[:IS]->(a)
and creates the IS
relationship between the two nodes. When the same query is run on Redis Graph, I get the following error:
Syntax error at offset 22 near 'MERGE'
. Does anyone know how to run the same query on Redis Graph?
I should add that CREATE
does not work instead of MERGE
since it will create a duplicate of an (possibly) already existing edge.
Currently, MERGE only functions as a standalone clause so it cannot be combined with other directives such as MATCH or RETURN.
Reference: Merge command, GitHub issue
You can do something like this (but it will create the whole pattern instead):
MERGE (u:USER {name: "John"})-[:IS]->(a:AGE {name: "28"})
So I think the only option for now is to perform two separate commands:
MATCH (u:USER {name: "John"})-[r:IS]->(a:AGE {name: "28"})
RETURN count(r)
If this transaction return empty result then you need to create the relationship:
MATCH (u:USER {name: "John"})
MATCH (a:AGE {name: "28"})
CREATE (u)-[:IS]->(a)
Edit: After 20-06-2020, this answer is not relevant since they are now support such queries.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With