我正在处理一个gremlin查询,它沿着几个边导航,并最终生成一个String。根据图的内容,这个遍历可能是空的。如果遍历结果为空,我希望返回一个默认值。
以下是我目前正在做的事情:
GraphTraversal<?, ?> traversal = g.traversal().V().
// ... fairly complex navigation here...
// eventually, we arrive at the target vertex and use its name
.values("nam
我在理解这些Gremlin查询时遇到了一些问题: from os import getenv
from gremlin_python.structure.graph import Graph
from gremlin_python.process.graph_traversal import __
from gremlin_python.driver.driver_remote_connection import DriverRemoteConnection
pmap = g.V().has(name, value) \
.union(__.hasLabel
图如下:
gremlin> a = graph.addVertex("name", "alice")
gremlin> b = graph.addVertex("name", "bobby")
gremlin> c = graph.addVertex("name", "cindy")
gremlin> d = graph.addVertex("name", "david")
gremlin> e = graph.addVertex(
当我尝试添加当前存在的边时,例如:
g.addE('person-ip').from(g.V('customer:testID')).to(g.V('tel:5555555555')).property(id, 'testEdgeId').next()
我得到一个类似这样的错误
{"message":"Edge with id already exists: testEdgeId","Exception-Class":"java.lang.IllegalArgumentExc
更新:我觉得很傻。决定只在db中查询所有名称的列表,然后list_of_names_in_db = g.V().hasLabel('Person').values('name').toList()将list_of_name_in_db与batch进行比较,并且只添加两个列表中没有的顶点。
在学习Gremlin一周多一点之后,我和我有了一个顶点表,我正在遍历这个表中的每个顶点,我正在检查它是否已经存在。如果没有,就创建它。我已经看过许多示例,但是没有一个示例使用inject()与coalesce协作。这是不可能的事,还是我做错了?以下是我尝试过的:
from g
我正在尝试使用描述的技术来防止gremlin中的重复边。我正在使用javascript,查询失败了,出现了以下错误:Server error: Neither the map, sideEffects, nor path has a v-key: WhereEndStep(v) (500)。这正是我所使用的查询:
import { process } from "gremlin";
const { statics } = process;
...
g
.V()
.has('user',
我有一个在Java上建模为实体和关系的my数据。其中每个实体具有关系列表。我们即将到来的请求可以有一个通过实体请求进入的实体列表,这些实体需要在GraphDB中创建(使用海王星),并使用gremlin访问它。我必须遍历实体列表一次,以创建图中的顶点,然后再次遍历实体,同时遍历每个关系以根据关系创建边。这不是处理这个问题的最优雅的方法,所以有没有办法优化我的数据模型和/或gremlin查询?请参阅下面的代码以供参考。
public class EntityRequest{
Set<Entity> entities;
// getter
// builder
// co