1
votes

I'm connecting to a remote JanusGraph server. There is no problem with the connection but I can't understand the Java API.

I'm running a Java Spring HTTP server. Inside the HTTP response method, I'm creating a graph traversal source like

GraphTraversalSource g = traversal().withRemote("conf/remote-graph.properties");

It seems fine. But When I want to get data about a Vertex I can not with the below code.

g.V(28712).next().keys()

IT GIVES AN EMPTY RESPONSE! WHY?

If I do the same with gremlin shell, I see it. See the below picture

enter image description here

If I do g.V(28712).valueMap(true).unfold().toList(); in Java, I see some results.

enter image description here

I just want to fetch data for a vertex or edge with Java. How should I do that?

thanks

1

1 Answers

2
votes

By default, when you connect to a Gremlin Server using one of the Gremlin clients and you ask for a vertex, what you get back is a reference vertex. A reference vertex just contains the ID and the label. To get some properties you need to include them using valueMap, elementMap, project etc. Alternatively you can configure the Gremlin Server to return all properties. The default is set this way to reduce the amount of data that gets sent back to a client.

Please see the documentation for further details.

https://tinkerpop.apache.org/docs/current/reference/#gremlin-applications

https://tinkerpop.apache.org/docs/current/reference/#_properties_of_elements

There is a link in that documentation to a post about why the decisions were made. For convenience, I am including that link here as well.

https://lists.apache.org/thread.html/e959e85d4f8b3d46d281f2742a6e574c7d27c54bfc52f802f7c04af3%40%3Cdev.tinkerpop.apache.org%3E