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

Adding Vertices in Batches

You can use a specific API provided by GES to add vertices in batches. The sample code is as follows:
public static void addBatchVertice(GraphClient graphClient) throws ApiException 
{
    // Construct a vertex property list.
    Map<String, List<Object>> properties = new HashMap<>();
    properties.put("movieid", Arrays.asList("180"));
    properties.put("title", Arrays.asList("testmoive"));
    properties.put("genres", Arrays.asList("Comedy"));

    // Construct the information of a single vertex.
    AddVertexReq vertex = new AddVertexReq();
    vertex.setVertexId("180");
    vertex.setLabel("movie");
    vertex.setProperties(properties);

    // Form the information of a batch of vertices.
    List<AddVertexReq> vertices = new ArrayList<>();
    vertices.add(vertex);

    // Construct a request for adding vertices in batches.
    AddBatchVertexReq addBatchVertexReq = new AddBatchVertexReq();
    addBatchVertexReq.setVertices(vertices);

    // Execute the request for adding vertices in batches.
    Map<String, Object> result = graphClient.addBatchVertex(addBatchVertexReq);
}