Search code examples
javaamazon-web-servicesaws-lambdagremlinamazon-neptune

Vertex.value() Property Not found Gremlin Neptune Java


I am accessing a neptune DataBase instance from a Lambda, I have successfully configured the connection of the neptune database from the lambda using the following

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

I have even sent update and insert statements to the database using

GraphTraversalSource g = traversal().withRemote(DriverRemoteConnection.using(cluster));
g.addV("Custom Label").property(T.id, "CustomId1").property("name", "Custom id vertex 1").next();

But when I try to retrieve properties of the vertex

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

I receive the error that the property name doesn't not exist on that vertex:

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

Can someone please let me know that is the mistake i am making here?


Solution

  • The vertex you get back from the query is known as a reference vertex. It will only contain an ID and a label. For properties you need you should explicitly ask for them using a step like values, project or valueMap.