英文:
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>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论