Gremlin: The provided traverser does not map to a value
Asked Answered
P

3

5
g.V()
    .has('atom', '_value', 'red').fold()
    .coalesce(unfold(), addV('atom').property('_value', 'red')).as('atom')
    .out('view').has('view', '_name', 'color').fold()
    .coalesce(unfold(), addE('view').from('atom').to(addV('view').property('_name', 'color')))

Gives me an error:

The provided traverser does not map to a value: []->[SelectOneStep(last,atom)] (597)

What does it mean?

Plossl answered 16/12, 2020 at 8:59 Comment(0)
P
4

So it looks like when as() is followed by fold() it deletes the variable set in the as() step. I used aggregate() instead as follows:

g.V()
    .has('atom', '_value', 'red')
    .fold().coalesce(
        unfold(), 
        addV('atom').property('_value', 'red')
    )
    .aggregate('atom')
    .out('view').has('view', '_name', 'color')
    .fold().coalesce(
        unfold(), 
        addE('view')
            .from(select('atom').unfold())
            .to(addV('view').property('_name', 'color'))
            .inV()
    )
Plossl answered 16/12, 2020 at 9:31 Comment(0)
A
5

Adding to this in case someone else comes across this.

This specific error occurs when you use the id as a string in from() instead of the vertex object.

To see what I mean, as a simple test run the following gremlin query:

g.addE('view').from('atom').to(addV('view').property('_name', 'color'))

then run this query:

g.addE('view').from(V('atom')).to(addV('view').property('_name', 'color'))

The first query will give you the error stated above, the second one will not.

Aristotle answered 1/5, 2021 at 16:46 Comment(0)
P
4

So it looks like when as() is followed by fold() it deletes the variable set in the as() step. I used aggregate() instead as follows:

g.V()
    .has('atom', '_value', 'red')
    .fold().coalesce(
        unfold(), 
        addV('atom').property('_value', 'red')
    )
    .aggregate('atom')
    .out('view').has('view', '_name', 'color')
    .fold().coalesce(
        unfold(), 
        addE('view')
            .from(select('atom').unfold())
            .to(addV('view').property('_name', 'color'))
            .inV()
    )
Plossl answered 16/12, 2020 at 9:31 Comment(0)
R
2

The as() step is what is known as a reducing barrier step. With reducing barrier steps any path history of a query (such as applying a label via as()) is lost. In reducing barrier steps many paths are reduced down to a single path. After that step there would be no way to know which of the many original labeled vertices would be the correct one to retrieve.

Ratline answered 16/12, 2020 at 16:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.