I'm trying to run a MERGE
query against an AWS Neptune database using their new OpenCypher implementation but MERGE
is not yet supported as a clause.
Is there a way to get the behaviour of a MERGE
without using a MERGE
in Neptune's OpenCypher implementation?
I'm hoping it's possible to do something like:
MATCH (ee:Person {name: "Sam"})
IF ee IS NULL THEN
CREATE ...
ELSE
SET ee += {...}
END
Obviously this is just pseudocode, but is there any way of achieving this behaviour without handling it in the application making the call?
openCypher does not provide a robust capability to perform the type of logic in a query that you show in your pseudocode. Until MERGE
is a supported clause in AWS Neptune the best way to achieve this functionality is to use the Gremlin pattern for this as described here. Neptune provides the ability to use both openCypher and Gremlin (via drivers or over HTTPS) on property graph data stored in Neptune. For your pseudo code above the Gremlin equivalent would look like this:
g.V().
has('Person', 'name', 'Sam').
fold().
coalesce(
addV('NEW LABEL').property('propertyName', 'foo'),
property('updateProperty', 'bar'))
UPDATE - As of the 1.1.0.0 version of Amazon Neptune the MERGE
clause is now supported.