查询

点查询

点ID主键查询

SearchNodesRequest request = new SearchNodesRequest();
request.setId(nodeId);
List<NodeAlias> res = client.searchNodes(request);

点过滤条件查询

查询10条ID大于5的点:

SearchNodesRequest request = new SearchNodesRequest();
request.setFilter(
 		Filter.newGtBuilder("id")
 			.gt(5)
 			.build()
);
request.setLimit(10);
List<NodeAlias> res = client.searchNodes(request);

自定义返回属性

查询返回字段name和age:

SearchNodesRequest request = new SearchNodesRequest();
request.setId(nodeId);
request.setSelectProperties(Arrays.asList("name", "age"));
List<NodeAlias> res = client.searchNodes(request);

边查询

边ID主键查询

查询Id为1的边:

SearchEdgesRequest request = new SearchEdgesRequest();
request.setId(1);
List<EdgeAlias> res = client.searchEdges(request);

边过滤条件查询

查询10条rank为55或60的边:

SearchEdgesRequest request = new SearchEdgesRequest();
request.setFilter(
		Filter
			.newInBuilder("rank")
			.in("55", "60")
			.build()
	);
request.setLimit(10);
List<EdgeAlias> res = client.searchEdges(request);

自定义属性返回

根据ID查询边并只返回rank字段:

SearchEdgesRequest request = new SearchEdgesRequest();
request.setId(edgeId);
request.setSelectProperties(Arrays.asList("rank"));
List<EdgeAlias> res = client.searchEdges(request);

AB路径查询

查询点1到2深度为3的5条路径:

SearchABRequest request = new SearchABRequest();
request.setSrc(1);
request.setDest(2);
request.setDepth(3);
request.setLimit(5);
List<Path> paths = client.searchAB(request);

K邻查询

查询点55,深度为2的5个邻居:

SearchKhopRequest request = new SearchKhopRequest();
request.setSrc(55);
request.setDepth(2);
request.setLimit(5);
List<NodeAlias> nodeAlias = client.searchKhop(request);

模板查询

模板查询提供了Template类进行参数构造:

查询n到e到n的路径模板:

TemplateRequest request = new TemplateRequest();
request.setTemplate(
		Template
        .newPath()
        .n()
        .e()
        .n()
        .build()
	);
Result result = client.template(request);
println(result);

使用别名Alias

查询返回路径点以及边:

TemplateRequest request = new TemplateRequest();
request.setTemplate(
		Template
            .newPath("p")
            .n("n1")
            .e("e1")
            .n("n2")
            .reTurn("p,n1,e1,n2")
            .limit(10)
            .build()
	);
Result result = client.template(request);

过滤条件

在模板路径中指定点属性name为”June Johnson”的过滤条件:

TemplateRequest request = new TemplateRequest();
request.setTemplate(
        Template
            .newPath("p")
            .n("n1", Filter.newEqBuilder("name").eq("June Johnson").build())
            .e("e1")
            .n("n2")
            .reTurn("p,nname,e1,n2")
            .limit(10)
            .build()
);
Result result = client.template(request);

模板KHOP

TemplateRequest request = new TemplateRequest();
request.setTemplate(
Template
	.newKhop()
	.n(Filter.newEqBuilder("id").eq("55").build())
	.e()
	.n()
	.build()
);
Result result = client.template(request);

自动组网

AutoNetRequest request = new AutoNetRequest();
request.setSrcs(Arrays.asList(1,2,3,4));
List<Path> result = client.autoNet(request);

自动展开

NodeSpreadRequest request = new NodeSpreadRequest();
request.setSrc(12);
request.setDepth(2);
request.setLimit(10);
Result result = client.nodeSpread(request);