import com.datastax.driver.dse.graph.GraphResultSet;
import com.datastax.driver.dse.graph.SimpleGraphStatement;
public class GraphExample {
public static void main(String[] args) {
DseCluster cluster = DseCluster.builder().addContactPoint("127.0.0.1").build();
DseSession session = cluster.connect();
String cqlQuery = "g.V().hasLabel('person').has('age', gt(30)).values('name')";
SimpleGraphStatement graphStatement = new SimpleGraphStatement(cqlQuery);
GraphResultSet result = session.executeGraph(graphStatement);
for (GraphResult graphResult : result) {
System.out.println("Name: " + graphResult.getString("name"));
}
session.close();
cluster.close();
}
}
yaml
storage:
cassandra:
keyspace: mykeyspace
index:
backend: dse
enabled: true
graph:
graph_name: mygraph
adjacency_list: out
system_query: "SELECT id, label, outE() as out, out().inV() as in FROM nodes WHERE id = 1"