MATCH (n0:ip)-[r0 :activeIn]-(n1:equipment)-[r2:login]-(n2: account) return DISTINCT n2.account.accountUuid
如果需要输出的是n1的出入度大于10的,要怎么写ngql?
MATCH (n0:ip)-[r0 :activeIn]-(n1:equipment)-[r2:login]-(n2: account) return DISTINCT n2.account.accountUuid
如果需要输出的是n1的出入度大于10的,要怎么写ngql?
参见 YIELD语句的文档说明
支持对输出结果作计算/过滤
YIELD [DISTINCT] <col> [AS <alias>] [, <col> [AS <alias>] ...]
[WHERE <conditions>];
你这个用例要转换成nGQL的话,需要先做好索引.
用LOOKUP找到出发点, 再用GO语句查询出边. 根据出入点id作分组, 计算出入度作过滤即可.
LOOKUP ON ip
YIELD vertex as v
| GO FROM $-.v over activeIn
WHERE head(labels($$)) == 'equipment'
YIELD id($$) as dst, id($^) as src
| GROUP BY $-.src, $-.dst YIELD $-.dst as dst WHERE COUNT(*) > 10
| GO FROM $-.dst over login
WHERE head(labels($$)) == 'account'
YIELD DISTINCT properties($$).accountUuid as accountUuid
你好 用了你提供的语句发现执行错误
修改如下:
LOOKUP ON ip YIELD id(vertex) as id
| GO FROM $-.id over activeIn
WHERE head(labels($$)) == 'equipment'
YIELD id($$) as dst, id($^) as src
| YIELD $-.src as src, $-.dst as dst, COUNT(*) as degree
| YIELD $-.dst as dst where $-.degree > 10
| GO FROM $-.dst over login
WHERE head(labels($$)) == 'account'
YIELD DISTINCT properties($$).accountUuid as accountUuid
参考@bofa1ex大佬的语句,最后写出来的是
LOOKUP ON ip YIELD id(vertex) as id
| GO FROM $-.id over activeIn REVERSELY
WHERE head(labels($$)) == 'equipment'
YIELD id($$) as dst, id($^) as src
| GO FROM $-.dst over login REVERSELY
WHERE head(labels($$)) == 'account'
YIELD id($$) as dst, id($^) as src
|GROUP BY $-.src YIELD $-.src as src,count($-.src) as degree
| YIELD $-.src as src where $-.degree > $p0
| GO FROM $-.src over login REVERSELY
YIELD properties($$).accountUuid as accountUuid
此话题已在最后回复的 7 天后被自动关闭。不再允许新回复。