Updated on 2022-09-14 GMT+08:00

Executing Gremlin Queries

You can use a specific API provided by GES to perform Gremlin queries. The sample code is as follows:

During graph client initialization, an object with the same name as the graph has been generated in the system. You can use the graph name to query the object.

  public static void executeGremlinQuery(GraphClient graphClient,String graphName) throws ApiException
{   //Gremlin command. An object with the same name as the graph is generated in the system during graph client initialization. You can directly use it as follows:
     String gremlinCommand = graphName + ".V(\"145\")";
     GremlinQueryReq req = new GremlinQueryReq();
     req.setCommand(gremlinCommand);
     Map<String, Object> stringObjectMap = graphClient.gremlinQuery(req);
     System.out.print(MapUtils.map2json(stringObjectMap));
}