搜索结果中丢失起始顶点

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

Losing starting vertex in search result

问题

我有一个图,我正在尝试从给定的顶点中找到特定的顶点,但在搜索结果中我没有找到起始顶点。以下是我正在尝试的查询,它丢失了起始顶点。

g.V().has("orgId", 102)
.repeat(bothE().otherV().simplePath())
until(hasLabel("ORG"));

如果我在has()函数之后使用emit(),它会打印出路径中出现的所有顶点,这是不需要的。我只需要根据until条件找到结束顶点。
我们可以尝试在这里执行:https://gremlify.com/w6o0d8htpt/8

但是,如果我们使用path(),它会在结果中给出起始顶点,但我们这里不需要路径。我只需要结束顶点。

英文:

I have graph, where i am trying to find certain vertex's from given vertex, but in the search result I am not getting the starting vertex. Below is the query I am trying which loose the starting vertex.

g.V().has("orgId", 102)
.repeat(bothE().otherV().simplePath())
.until(hasLabel("ORG"));

If I use emit() after has() function it prints all the the vertex's coming in the path, which is not required. I only need the ending vertex based on until condition.
We can try and execute here https://gremlify.com/w6o0d8htpt/8

Where as if we go for path(), it gives the starting vertex in the result, but we do not need path here. I am only looking for ending vertex.

答案1

得分: 0

"union() 步骤应该在这里很好地完成任务:

    __.identity(),
    __.repeat(bothE().otherV().simplePath())
       .until(hasLabel("ORG"))
    );
```"

<details>
<summary>英文:</summary>

The union() step should do fine here:

g.V().has("orgId", 102).union(
__.identity(),
__.repeat(bothE().otherV().simplePath())
.until(hasLabel("ORG"))
);


</details>



huangapple
  • 本文由 发表于 2023年2月27日 19:00:38
  • 转载请务必保留本文链接:https://go.coder-hub.com/75579607.html
匿名

发表评论

匿名网友

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

确定