© 2026 Hedgehog Software, LLC

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

I am not sure how to use mergeE and mergeV using gremlin_python

I am using janusgraph with cassandra for my project and I want to implement upsert functionality. For that I didn't find much resources, only this gist (https://gist.github.com/spmallette/5cd448f38d5dae832c67d890b576df31) . From that, I wrote certain code which does work. The code looks like this
For vertex/node
g.merge_v({T.id: node.id}).option(
            Merge.on_create, {
                T.label: node.type.value,
                'name': node.name
            }
        ).option(
            Merge.on_match, {
                'name': node.name
            }
        ).property("full_name": node.full_name) \
        .next()
For vertex/node
g.merge_v({T.id: node.id}).option(
            Merge.on_create, {
                T.label: node.type.value,
                'name': node.name
            }
        ).option(
            Merge.on_match, {
                'name': node.name
            }
        ).property("full_name": node.full_name) \
        .next()

For edge
g.merge_e({T.label: edge.relationship.value,
                                    Direction.from_: edge.from_.id,
                                    Direction.to: edge.to_.id})\
                .option(Merge.on_create, {
                    T.label: edge.relationship.value
                }) \
                .option(Merge.on_match, {
                    'updated': "true"
                }).property("description": edge.description).next()
For edge
g.merge_e({T.label: edge.relationship.value,
                                    Direction.from_: edge.from_.id,
                                    Direction.to: edge.to_.id})\
                .option(Merge.on_create, {
                    T.label: edge.relationship.value
                }) \
                .option(Merge.on_match, {
                    'updated': "true"
                }).property("description": edge.description).next()

In the edge, I don't want an "updated" thing to be there but if I keep the dictionary empty for the options, it throws the error. Let me know if I am doing it wrong or not. Should I place the values in the
.property()
.property()
or should I keep the changes in the
options
options
?
Gist
Gremlin merge() API
Gremlin merge() API. GitHub Gist: instantly share code, notes, and snippets.
Gremlin merge() API
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

How to improve Performance using MergeV and MergeE?
Apache TinkerPopATApache TinkerPop / questions
17mo ago
Gremlin python MergeV update properties
Apache TinkerPopATApache TinkerPop / questions
13mo ago
gremlin-go, MergeE, and Neptune
Apache TinkerPopATApache TinkerPop / questions
3y ago
using mergeV/E
Apache TinkerPopATApache TinkerPop / questions
4y ago