Gremlingo:在两个顶点之间添加边时,Traverser无法映射到值。

huangapple go评论88阅读模式
英文:

Gremlingo: Traverser does not map to value when adding edge between two vertices

问题

我正在使用tinkerpop的gremlin-go库来访问gremlin-server/JanusGraph。在尝试创建两个顶点之间的边时,我遇到了以下错误:

The provided traverser does not map to a value: ...

顶点是通过以下方式添加的:

t.AddV("somenode").Property("some_id", someID).Iterate()

t.AddV("someothernode").Property("some_id", someID).Iterate()

其中t*gremlingo.GraphTraversal。顶点成功添加。

边是通过以下方式添加的:

t.AddE("someedge").
	From(
		__.V().
			HasLabel("somenode").
			Has("some_id", someID),
	).
	To(
		__.V().
			HasLabel("someothernode").
			Has("some_id", someID),
	).
    Iterate()

这里的t仍然是*gremlingo.GraphTraversal__gremlingo.T__的别名。但是边没有创建,并显示上述错误。

在gremlin-console中,通过以下方式添加边g.addE("someedge").from(__.V().hasLabel("somenode").has("some_id","some_id_1")).to(__.V().hasLabel("someothernode").has("some_id","some_id_1")),其中g是遍历器,可以正常工作。

请注意,我省略了go错误处理部分。

英文:

I am using tinkerpop gremling-go to access gremlin-server/JanusGraph. When trying to create an edge between two vertices, I get the following error

The provided traverser does not map to a value: ...

Vertices are added via

t.AddV("somenode").Property("some_id", someID).Iterate()

and

t.AddV("someothernode").Property("some_id", someID).Iterate()

where t is *gremlingo.GraphTraversal. Vertices are added successfully.

Edge is added via

t.AddE("someedge").
		From(
			__.V().
				HasLabel("somenode").
				Has("some_id", someID),
		).
		To(
			__.V().
				HasLabel("someothernode").
				Has("some_id", someID),
		).
        Iterate()

where again t is *gremlingo.GraphTraversal and __ is alias for gremlingo.T__. Edge is not created with error output above.

Using gremlin-console adding edge via g.addE("someedge").from(__.V().hasLabel("somenode").has("some_id","some_id_1")).to(__.V().hasLabel("someothernode").has("some_id","some_id_1")) where g is the traversal works just fine.

Note that I left out go error handling.

答案1

得分: 0

你等待异步请求完成了吗?

channel := t.AddV("somenode").Property("some_id", someID).Iterate()

err := <-channel

英文:

Did you wait for async request completion?

channel := t.AddV(&quot;somenode&quot;).Property(&quot;some_id&quot;, someID).Iterate()

err := &lt;-channel

huangapple
  • 本文由 发表于 2022年11月18日 18:59:08
  • 转载请务必保留本文链接:https://go.coder-hub.com/74488633.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定