SHOW QUERY,这里有社区用户常用的 nGQL 查询语句

  • 语句 1
    • 场景:如何进行数据统计,分别用 LOOKUP、MATCH 和 SHOW STATS
    • 具体语句:以统计某条边为例子,记得 MATCH 需要创建索引,如果是导入数据后创建的索引,记得进行 REBUILD INDEX 操作。
    # LOOKUP
    lookup on edge_name yield edge as e | yield count(*)
    # MATCH
    match (m) - [e:edge_name] - (n) return count(e)
    # SHOW STATS 
    看文档:https://docs.nebula-graph.com.cn/3.4.1/3.ngql-guide/7.general-query-statements/6.show/14.show-stats/
    
  • 语句 2
  • 语句 3
    • 场景:根据属性删除对应边
    • 具体语句:
    Lookup on `in_user` where in_user.user_type == 2 yield src(edge) as src, dst(edge) as dst | delete edge `in_user` $-.src->$-.dst
    
  • 语句 4
    • 场景:删除没有边的点
    • 具体语句:
    lookup on player yield id(vertex) as vid  
    minus 
    (lookup on player yield id(vertex) as vid | go 1 step from $-.vid over * bidirect yield distinct id($^) as vid)
    )
    | delete vertex $-.vid
    
1 个赞