辅助类 NebulaResult.java 等外层结构这里定义了 json 格式响应的外层结构
@Datapublic class NebulaResult<T> implements Serializable {private List<Error> errors;private List<Result<T>> results;@JsonIgnorepublic boolean isSuccess() {return (errors != null && errors.size() == 1 && errors.get(0).getCode() == 0);}@Datapublic static class Error implements Serializable {private int code;}@Data@JsonIgnoreProperties(ignoreUnknown = true)@JsonInclude(JsonInclude.Include.NON_NULL)public static class Result<T> implements Serializable {private String spaceName;private List<Element<T>> data;private List<String> columns;private Error errors;private long latencyInUs;}@Datapublic static class Element<T> implements Serializable {private List<Meta<T>> meta;private List<Serializable> row;}@Datapublic static class Meta<T> implements Serializable {private String type;private T id;}}
内层因为区分Edge和Vertex, 结构不一样. 如果是混合返回的结果, 可以用 Serializable
String gql = "match (v:ADDR)-[e]-() where id(v)==\"ADD:123123\" return v,e limit 100";NebulaResult<Serializable> res = graphService.query("insurance", gql);log.info(JacksonUtil.compress(res));Assertions.assertThat(res).isNotNull();
对于边, 需要使用结构化的ID
@Data@JsonIgnoreProperties(ignoreUnknown = true)@JsonInclude(JsonInclude.Include.NON_NULL)public class EdgeId implements Serializable {private int ranking;private int type;private String dst;private String src;private String name;}
用这个结构进行查询
NebulaResult<EdgeId> res3 = graphService.query("t_test1", "MATCH ()-[e:follow]-() RETURN e");
对于点, ID就是String
NebulaResult<String> res2 = graphService.query("t_test1", "MATCH (v:player) RETURN v");
经验总结扩展阅读
- 电影后会无期剧情介绍?
- 电影大上海剧情介绍?
- 电影女儿谷剧情介绍?
- 电影小姐剧情详细介绍?
- 电影宫锁沉香详细剧情介绍?
- 电影甩尾王2的演员介绍?
- 电影一生一世剧情介绍?
- 电影51号兵站剧情介绍?
- iqoou3详细参数_iqoou3参数详细参数配置
- 电视剧甜了青梅配竹马演员表介绍?