hugegraph的接口有很多都是基于顶点的id做的查询
hugegraph的接口有很多都是基于顶点的id做的查询,例如Shortest Path、K-out、K-neighbor 能给个loader 指定id的案例吗,我看现在都是基于primarykey的
或者接口怎么不按照id使用这些接口(Shortest Path、K-out、K-neighbor)也行
第一个问题,Loader 只是一个导入工具,并不提供查询能力。如果你是想要 Loader 指定顶点 Id 进行导入的话,下面是一个例子:
元数据定义 schema.groovy
// Define schema
schema.propertyKey("name").asText().ifNotExist().create();
schema.propertyKey("age").asInt().ifNotExist().create();
schema.propertyKey("city").asText().ifNotExist().create();
// 使用自定义数字Id策略
schema.vertexLabel("person").properties("name", "age", "city").useCustomizeNumberId().ifNotExist().create();
输入映射文件 struct.json:
{
"vertices": [
{
"label": "person",
"input": {
"type": "file",
"path": "example/vertex_person.csv",
"format": "CSV",
"header": [
"id",
"name",
"age",
"city"
],
"charset": "UTF-8"
},
"id": "id"
}
]
}
数据文件 example/vertex_person.csv
// 第一列为id列
1,marko,29,Beijing
2,vadas,27,Hongkong
3,josh,32,Beijing
4,peter,35,Shanghai
第二个问题,目前这些接口实现的算法,基本上都是有一个起始顶点才有意义。比如 K-out,找的是从一个点向外扩散指定次数能到达的点,如果不指定起始点,而试图去寻找每一个点向外扩散能走到的点,结果无疑是巨大的。请问你具体是什么样的场景需要这样的查询方式呢?
thanks, 如果是创建边就是 source_name和target_name改成id是吧 "edges": [ { "label": "knows", "source": ["source_name"], "target": ["target_name"], "input": { "type": "file", "path": "example/edge_knows.json", "format": "JSON" }, "mapping": { "source_name": "id", "target_name": "id" } }
是的,在我给出的这个例子里面就是像你那样写的。此时的边文件大概是:
// source_name,target_name,prop1
100,200,xxx
101,201,xxx
...