Search code examples
amazon-neptuneopencypher

Insert an array into a node property in Amazon Neptune using openCypher


I am trying to insert an array into a node property in Amazon Neptune using openCypher. Is there a way to do this with openCypher ?

I have tried the following query :

MERGE (n:Test { name: 'test', colors : ['blue', 'yellow'] })

Error message : "detailedMessage": "Expected a simple literal but found List."

If it's not supported how could AWS release it for production if this basic feature is not yet available.


Solution

  • Neptune only supports Set-based array properties, which are not supported in openCypher specification.

    Neptune does support comparable functionality to what you are looking to achieve through the split() and join() functions as shown here: https://docs.aws.amazon.com/neptune/latest/userguide/migration-opencypher-rewrites.html#migration-opencypher-rewrites-lists

    //For writing data
    MERGE (n:Test { name: 'test', colors : 'blue, yellow'})
    
    //For reading data
    MATCH (n:Test
        WITH n, [tag in split(n.colors, ',') WHERE NOT (color IN ['blue', 'yellow'])] AS colors
        RETURN n