【发布时间】:2019-04-04 14:19:34
【问题描述】:
我正在尝试向远程 gremlin 服务器上的现有顶点添加属性。
以下是顶点的创建方式:
String LABEL = "label";
String NAME = "name";
String ID = "id";
String TEST = "test";
GryoMessageSerializerV3d0 serializer = new GryoMessageSerializerV3d0(GryoMapper.build().addRegistry(TinkerIoRegistryV3d0.instance()));
cluster = Cluster.build().addContactPoint("localhost").port(8182).serializer(serializer).create();
client = cluster.connect();
Graph graph = EmptyGraph.instance();
GraphTraversalSource g = JanusGraphFactory.open("/Users/user/Documents/stage/tinkerPop/Project/janusgraph-eval/janusgraph-0.3.1/conf/gremlin-server/janusgraph-cql-es-server.properties").traversal().withRemote(DriverRemoteConnection.using(cluster));
final Bindings b = Bindings.instance();
Vertex v1 = g.addV(b.of(LABEL, "transaction")).property(NAME, b.of(NAME, nameOfVertex1)).property(ID, b.of(ID, id1)).next();
这样做:
g.V(v1).property(VertexProperty.Cardinality.single, TEST, b.of(TEST, "test")).next();
或者这个:
GraphTraversal v1 = g.addV(b.of(LABEL, "transaction")).property(NAME, b.of(NAME, nameOfVertex1)).property(ID, b.of(ID, id1));
v1.property(VertexProperty.Cardinality.single, TEST, b.of(TEST, "test")).next();
给我以下错误:
java.util.concurrent.CompletionException: org.apache.tinkerpop.gremlin.driver.exception.ResponseException: The type of given name is not a key: test
我查看了 tinkerpop 文档和各种教程/网站,但我只找到了一种添加属性属性的方法 (cf How to add property to vertex property in java?)
您知道如何将新属性添加到已经存在的顶点吗?
【问题讨论】:
标签: gremlin janusgraph gremlin-server