Vertex.value() 属性 未找到 Gremlin Neptune Java

Vertex.value() Property Not found Gremlin Neptune Java

我正在从 Lambda 访问一个海王星数据库实例,我已经使用以下命令从 lambda 成功配置了海王星数据库的连接

Cluster.Builder builder = Cluster.build();
builder.addContactPoint("endpoint");
builder.port(8182);
builder.enableSsl(true);
builder.keyCertChainFile("SFSRootCAG2.pem"); 

我什至使用

向数据库发送更新和插入语句
GraphTraversalSource g = traversal().withRemote(DriverRemoteConnection.using(cluster));
g.addV("Custom Label").property(T.id, "CustomId1").property("name", "Custom id vertex 1").next();

但是当我尝试检索顶点的属性时

Vertex vertex = g.V().has(T.id, "CustomId1").next(); System.out.println((String) vertex.value("name"));

我收到 属性 名称在该顶点上不存在的错误:

org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.IllegalStateException: The property does not exist as the key has no associated value for the provided element: v[CustomId1]:name

有人可以告诉我这是我在这里犯的错误吗?

您从查询中得到的顶点称为参考顶点。它只包含一个 ID 和一个标签。对于您需要的属性,您应该使用 valuesprojectvalueMap 等步骤明确要求它们。