Gremlin 使用更简单的格式获取顶点
有没有办法以更简单的格式获取顶点列表? 目前,以下查询:Gremlin 使用更简单的格式获取顶点,gremlin,tinkerpop3,janusgraph,Gremlin,Tinkerpop3,Janusgraph,有没有办法以更简单的格式获取顶点列表? 目前,以下查询: g.V().has(label, 'Quantity').has('text', '627 km'); 返回如下所示的对象: { "id": 42545168, "label": "Quantity", "type": "vertex", "properties": { "sentence": [ { "id": "pkbgi-pbw28-745",
g.V().has(label, 'Quantity').has('text', '627 km');
返回如下所示的对象:
{
"id": 42545168,
"label": "Quantity",
"type": "vertex",
"properties": {
"sentence": [
{
"id": "pkbgi-pbw28-745",
"value": "null"
}
],
"updated_text": [
{
"id": "pk9vm-pbw28-5j9",
"value": "627 km"
}
],[...]
当我得到一个边列表时,它的格式更简单:
g.E().has(label, 'locatedAt').has('out_entity_id','41573-41579');
返回:
{
"id": "ozfnt-ip8o-2mtx-g8vs",
"label": "locatedAt",
"type": "edge",
"inVLabel": "Location",
"outVLabel": "Location",
"inV": 758008,
"outV": 872520,
"properties": {
"sentence": "Bolloré is a corporation (société anonyme) with a Board of Directors whose registered offi ce is located at Odet, 29500 Ergué-Gabéric in France.",
"in_entity_id": "41544-41548",
"score": "0.795793",
"out_entity_id": "41573-41579"
}
}
怎么会这样?
有没有办法用这种方式格式化顶点?我的建议是,不要让查询返回整个顶点,而是返回您感兴趣的特定属性。例如,顶点ID或您感兴趣的某些选定特性或valueMap。否则你得到的基本上就是一切。这与SQL中尝试不执行“选择*”而只选择您真正关心的内容是一样的 编辑以添加返回匹配顶点ID的示例
g.V().has(label, 'Quantity').has('text', '627 km').id().fold()
将产生如下结果
{"requestId":"73f40519-87c8-4037-a9fc-41be82b3b227","status":{"message":"","code":200,"attributes":{}},"result":{"data":[[20608,28920,32912,106744,123080,135200,139296,143464,143488,143560,151584,155688,155752,159784,188520,254016,282688,286968,311360,323832,348408,4344,835648,8336,1343616,12352]],"meta":{}}}