Subgraph query returns String instead of TinkerGraph Object in Fluent Java API
Hi guys.
I am running the following query in the console and it works fine:
g.V().has('user', 'id', 'Andrei').repeat(bothE().subgraph("subgraph").otherV().simplePath()).dedup().cap("subgraph").next();
I can then do a .traversal()
on the Thinkergraph result.
When I am using the Tinkerpop Java API, the next() step returns the following as a String: tinkergraph[vertices:11 edges:11]
How am I able to view the Edges and Vertices of my subgraph in Java? Per my understanding, a TinkerGraph should have been returned instead of String so I could run .traversal()
on it.
Thank you!8 Replies
My guess is that you are using the wrong serializer in your Java configuration. There is a configuration on serializers called
serializeResultToString: true
which basically just says take every result and call toString()
on it, which is really helpful when connecting with a text based tool like Gremlin Console or sometimes for debugging. If you want an Object
returned you'll want to set that to false
or more simply, just remove the key/value all together.HI @spmallette Thank you for your suggestion. Unfortunately I am getting the same behaviour.
I am running a Cassandra DSE with Graph. I have updated the server configuration based on the information from this doc: https://docs.datastax.com/en/dse/6.8/dse-admin/datastax_enterprise/config/configRemoteYaml.html#DSGGremlinbasicoptions
remote.yaml configuration file
The DataStax Enterprise configuration file for the DataStax Graph Gremlin console connection to the Gremlin Server.
The link you provided has
serializeResultToString: true
. That value on the client should be false
or the key removed. Perhaps you should share the code/configuration you use to connect to the server.
(note that this shouldn't be a server side change that you need to make. the server can have a serializeResultToString: true
configuration option. that just means that the server can respond serialization requests of that type)Understood.
On the client(Java app) this is my configuration;
@Bean
public CqlSession cqlSession () {
return CqlSession.builder()
.addContactPoint(new InetSocketAddress(host, port))
.withLocalDatacenter(dcName)
.withAuthCredentials(userName, password)
.withKeyspace(keyspace)
.build();
}
@Bean
public GraphTraversalSource graphTraversalSource(CqlSession cqlSession) {
return AnonymousTraversalSource.traversal().withRemote(DseGraph.remoteConnectionBuilder(cqlSession)
.withExecutionProfile(cqlSession.getContext().getConfig().getDefaultProfile()
.withString(DseDriverOption.GRAPH_NAME, keyspace)).build());
}
hmm - what version of TinkerPop are you using?
3.6.2. I have tried downgrading to 3.5 but same
This is my pom.xml
<dependency>
<groupId>com.datastax.oss</groupId>
<artifactId>java-driver-query-builder</artifactId>
<version>${dse.driver.version}</version>
</dependency>
<dependency>
<groupId>com.datastax.oss</groupId>
<artifactId>java-driver-mapper-runtime</artifactId>
<version>${dse.driver.version}</version>
</dependency>
<dependency>
<groupId>org.apache.tinkerpop</groupId>
<artifactId>gremlin-core</artifactId>
<version>${tinkerpop.version}</version>
</dependency>
<dependency>
<groupId>org.apache.tinkerpop</groupId>
<artifactId>tinkergraph-gremlin</artifactId>
<version>${tinkerpop.version}</version>
</dependency>
I was also reading this section:
https://tinkerpop.apache.org/docs/3.5.2/reference/#connecting-gremlin-server-limitations
Is GraphBinary serialization configuration on the server side a possible fix?i'm not terribly familiar with DS Graph these days so I'm not sure what's going on here. the problem definitely has something to do with the server doing a
toString()
serialization, but I'm not sure why it would do that. I do note that you are using CqlSession
and the DseGraph
related RemoteConnection
implementation. I wonder if their serializer isn't setup right? i would try to connect with the standard TinkerPop driver which should have the serializer configured correctly be default and see if that makes any difference. i'd also be wary of using the latest version of TinkerPop with DS Graph. I can't recall exactly what version they support, but you may want to go back as far as 3.4.13 to be safe. maybe some folks from @datastaxgraph are around and could jump into help as i'm not sure what else to try at this point@datastaxgraph Your help would be much appreciated.