© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Apache TinkerPopAT
Apache TinkerPop•13mo ago•
13 replies
masterhugo

Gremlin python MergeV update properties

I'm working with gremlin python 3.7.1 and AWS Neptune 1.3.2.1, and I'm trying to update vertex properties with MergeV().option(OnMatch, {...}), however the behavior isn't what I expect, it should be a=b but appears to be a=[c.b] where c is the old value. Someone knows how to implement correctly this behavior with MergeV?
Solution
If I'm understanding your question correctly, I think what you are seeing is a result of Neptune defaulting to
set
set
cardinality for properties. Essentially what that means, is if I start with a vertex with
property("name", "Alice")
property("name", "Alice")
, and I try to overwrite the property with
property("name", "Bob")
property("name", "Bob")
Neptune will instead add the new property to a set such that
vertex.name = {"Alice", "Bob"}
vertex.name = {"Alice", "Bob"}
. I think this is what you are seeing this set cardinality behaviour when using MergeV().

If you want to use mergeV and enforce single cardinality for properties (overwrite existing values instead of appending), you can try a query like this:

from gremlin_python.process.traversal import Merge, T, CardinalityValue

g.merge_v({T.id_: "x1234"})
        .option(Merge.on_create, {T.label: 'Dog', 'name': 'Toby', 'age': 10})
        .option(Merge.on_match, {'age': CardinalityValue.single(11)})
        .toList()
from gremlin_python.process.traversal import Merge, T, CardinalityValue

g.merge_v({T.id_: "x1234"})
        .option(Merge.on_create, {T.label: 'Dog', 'name': 'Toby', 'age': 10})
        .option(Merge.on_match, {'age': CardinalityValue.single(11)})
        .toList()
Jump to solution
Apache TinkerPop banner
Apache TinkerPopJoin
Apache TinkerPop is an open source graph computing framework and the home of the Gremlin graph query language.
1,376Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

I am not sure how to use mergeE and mergeV using gremlin_python
Apache TinkerPopATApache TinkerPop / questions
13mo ago
MergeV uint32 properties inserted as long
Apache TinkerPopATApache TinkerPop / questions
3y ago
Optimising python-gremlin for fastApi
Apache TinkerPopATApache TinkerPop / questions
2y ago
Setting index in gremlin-python
Apache TinkerPopATApache TinkerPop / questions
2y ago