Pass label to coalesce

When I want to pass a label to a coalesce step I get follwoing error:
"addE(occupied) failed because the from() traversal (which should give a Vertex) failed with: The provided traverser does not map to a value: v[10190][TinkerVertex]->[SelectOneStep(last,u,null)
"addE(occupied) failed because the from() traversal (which should give a Vertex) failed with: The provided traverser does not map to a value: v[10190][TinkerVertex]->[SelectOneStep(last,u,null)
this is my code:
g.addV('user').property('name', 'mari').as('u').
out().has('location','name', "Z").fold().
coalesce(
__.unfold(),
__.addV('location').property('name', "Z").as("loc").
addE('occupied').from('u').to('loc')
)
g.addV('user').property('name', 'mari').as('u').
out().has('location','name', "Z").fold().
coalesce(
__.unfold(),
__.addV('location').property('name', "Z").as("loc").
addE('occupied').from('u').to('loc')
)
Appreciate your help
2 Replies
spmallette
spmallette11mo ago
A fold() step is a type of reducing barrier step. Those steps destroy the path history along which Gremlin has travelled. Therefore "u" is no longer accessible. In most cases, it's relatively easy to work around this limitation by using a side-effect:
gremlin> g.addV('user').
......1> property('name', 'mari').store('u').
......2> out().
......3> has('location', 'name', "Z").
......4> fold().
......5> coalesce(
......6> __.unfold(),
......7> __.addV('location').
......8> property('name', "Z").
......9> addE('occupied').from(select('u').unfold()))
==>e[4][0-occupied->2]
gremlin> g.addV('user').
......1> property('name', 'mari').store('u').
......2> out().
......3> has('location', 'name', "Z").
......4> fold().
......5> coalesce(
......6> __.unfold(),
......7> __.addV('location').
......8> property('name', "Z").
......9> addE('occupied').from(select('u').unfold()))
==>e[4][0-occupied->2]
isohrab
isohrab11mo ago
@spmallette thank you so much for your help. I could solve my problem with the help of your answer.
Want results from more Discord servers?
Add your server
More Posts
Can I use a query to export data in the form of a query?In the SQL world you can use SQL Developer to generate INSERT statements from the results of a queryGremlin query to give response for 1 and 2 hops at same timeI have a graph setup with certain type of vertices like: inputFiles, outputFiles, convertors conveConnect and work with JGHi Guys. I'm looking for assistance with connecting to a JanusGraph database using Angular and TypeSAdd Multiple addV() by one IterateHello guys, I have crazy question which needs some experts to help me. I am using C# to add many nodMetricRegistry DocumentationIs there documentation anywhere on the metrics provided by the `MetricRegistry` and what their meaniHow do I enable Dynamic Graphs while using the default Docker image `janusgraph/janusgraph:latest`?With the following configuration settings and using the default `g` alias I can work with gremlin/JaEncounter strange behaviors in "match()" stepHello! Sorry for bothering you once again. When I further investigate the problem I post at https://[parameterized queries] Increased time in query evaluation when gremlin server starts/restartsHi folks, High latency observed in query evaluation time whenever janusgraph server restarts/startsGremlin Statement for Adding Edges Based on Existence of Other EdgesI'm trying to figure out how to do the following in Gremlin with Kelvin's air-routes data. I want toGremlin Python 3.4.13 - Exception Ignored Message When Existing A Python Main**What Happens** This happens in Gremlin Python 3.4.13 1. Open `self.connection = DriverRemoteConn