Executing graph queries

DseSession has dedicated methods to execute graph queries.

A graph query can be executed either via the executeGraph() method which accepts a string Gremlin-groovy script in parameter, or the recommended executeGraph() method that accepts a GraphStatement. The recommended way to create GraphStatements to execute is via the Fluent API module.

The following snippet is a fully functional example. It creates a new DSE Graph and sets the graph schema to development mode, which allows to bypass the schema creation phase of DSE Graph in order to learn how to use DSE Graph and experiment, but this setting is not recommended for production and is just a guide to get started quickly:

// -- DSE Graph setup --

// WARNING: these settings are not recommended for Production! These are only used here
// for demonstration purposes. Check the DSE Graph Schema documentation for more information.
// -- end DSE Graph setup --

GraphTraversalSource g = DseGraph.traversal();

GraphStatement s1 = DseGraph.statementFromTraversal(g.addV("testLabel"));

GraphStatement s2 = DseGraph.statementFromTraversal(g.V());
GraphResultSet grs = dseSession.executeGraph(s2);
Asynchronous execution

GraphStatement can also be executed asynchronously via the executeGraphAsync() methods.