Cannot update a property in a graph vertex with an array of values (Neptune)

26 Views Asked by At

Following the instructions of Neptune, Python, Gremlin: Update a property in a graph vertex with an array of values, I created this query g.V('{node_id}').as('node').values('sentenceIDs').as('sentenceIDs').select('node').property(set,'sentenceIDs_asList',select('sentenceIDs')) that should fetch the values of the vertex's property sentenceIDs (which is a list of uuids as string in the form "['e0a0efad-0ce4-4f16-852d-21dfd5628206', 'd35bcb4f-3a4e-471b-915a-a9bcb7c542ad', 'f7fd50e4-eb66-4333-bb25-1dd7f3ecd0b5']") and put them as an array in the property sentenceIDs_asList. However, it's not working since the new property consists of the same list as string, as in the original property sentenceIDs. I assume the whole problem is having the list as a string in the first place. The motivation is that I need to be able to fetch vertexes by the uuids that are listed in their sentenceIDs property, which should be an array of values. I'm using AWS Neptune DB. How to proceed?

1

There are 1 best solutions below

1
Kelvin Lawrence On

To do this you would need some way to split the string up. The very latest TinkerPop version (3.7) adds a selection of new string manipulation functions.

Once Neptune moves up to that level, doing this all in Gremlin will be simple. Unfortunately, until then, if the original list is really a long string, there is no way to break that up all in Gremlin and you will need to do this as two queries. The first to fetch the string, then a second (after an application splits it up) to add the values as a set.