Gremlin with AWS Neptune

Hey Friends, I am working on a project using AWS Neptune with gremlin query language on gremlingo driver. I realize the latest version of neptune is 1.3.1, and tinkerpop version is 3.6.4. I want to write a query to batch upsert property and then build edge. The relationship looks like the following: (User) -> [:HAS_USER_ACCOUNT] -> (GremlinUser) I am trying to use mergeV to upsert vertice and mergeE to upsert edge g. MergeV(map[interface{}]interface{}{ gremlingo.T.Id: universalId, }). Option(gremlingo.Merge.OnCreate, gremlinUserOnCreate). Option(gremlingo.Merge.OnMatch, gremlinUserOnMatch). Id(). MergeV(map[interface{}]interface{}{ gremlingo.T.Id: userUUID, gremlingo.T.Label: "User", "email": user["email"], }). Option(gremlingo.Merge.OnCreate, parentUserOnCreate). Option(gremlingo.Merge.OnMatch, parentUserOnMatch). Id(). MergeE(map[interface{}]interface{}{ gremlingo.T.Label: "HAS_USER_ACCOUNT", gremlingo.Direction.Out: gremlingo.Merge.OutV, gremlingo.Direction.In: gremlingo.Merge.InV, }). Option(gremlingo.Merge.OutV, map[interface{}]interface{}{ gremlingo.T.Label: "User", "email": user["email"], }). Option(gremlingo.Merge.InV, map[interface{}]interface{}{ gremlingo.T.Label: "GremlinUser", "email": user["email"], }). Id().Next() Conditions I have: 1. if the email can not be found, i am expecting to silent ignoe it, there is scenario that email can not be found for mergeE scenario 2. mergeV/mergeE does not handle single cardinality properly, it always add property to a set, I can not find a neat way to by pass it in tinkerpop 3.6.4
Solution:
note that Neptune 1.3.2.1 now supports the functionality of TinkerPop 3.7.x. You can read more about it at https://aws.amazon.com/blogs/database/exploring-new-features-of-apache-tinkerpop-3-7-x-in-amazon-neptune/
Amazon Web Services
Exploring new features of Apache TinkerPop 3.7.x in Amazon Neptune ...
Amazon Neptune 1.3.2.0 now supports the Apache TinkerPop 3.7.x release line, introducing many major new features and improvements. In this post, we highlight the features that have the greatest impact on Gremlin developers using Neptune, to help you understand the implications of upgrading to these versions of Neptune and TinkerPop.
Jump to solution
4 Replies
triggan
triggan6mo ago
The upgrade doc that discusses the ability to do this in 3.7.x also shows what the work around was previously: https://tinkerpop.apache.org/docs/current/upgrade/#_map_and_cardinality
g.mergeV([(T.id): '1234']).
option(onMatch, sideEffect(property(single,'age', 20).
property(set,'city','miami')).constant([:]))
g.mergeV([(T.id): '1234']).
option(onMatch, sideEffect(property(single,'age', 20).
property(set,'city','miami')).constant([:]))
You would have to make use of sideEffect within the option() to define cardinality for the property.
supercoal
supercoal6mo ago
so there is no way for me to do it in neptune, which only supports 3.6.4...
Solution
spmallette
spmallette4mo ago
note that Neptune 1.3.2.1 now supports the functionality of TinkerPop 3.7.x. You can read more about it at https://aws.amazon.com/blogs/database/exploring-new-features-of-apache-tinkerpop-3-7-x-in-amazon-neptune/
Amazon Web Services
Exploring new features of Apache TinkerPop 3.7.x in Amazon Neptune ...
Amazon Neptune 1.3.2.0 now supports the Apache TinkerPop 3.7.x release line, introducing many major new features and improvements. In this post, we highlight the features that have the greatest impact on Gremlin developers using Neptune, to help you understand the implications of upgrading to these versions of Neptune and TinkerPop.
Want results from more Discord servers?
Add your server