Get SubGraph filter 问题

  • nebula 版本:v3.4.1
  • 部署方式: 分布式
  • 安装方式: RPM
  • 是否上生产环境:Y
  • 硬件信息
    • 磁盘( 推荐使用 SSD)
    • CPU、内存信息
  • 问题的具体描述
  • 相关的 meta / storage / graph info 日志信息(尽量使用文本形式方便检索)
GET SUBGRAPH WITH PROP 2 STEPS FROM "2603d4a4b1f04ebd1435f8adf30cbc7a" BOTH Invest, Employ, Legal where $$.Company.valid == false and $$.Person.valid == false  YIELD VERTICES as v, Edges as e

想获取某个点的2 hop 子图,图中有Person,Company 两种Entity, 都有valid(bool 类型) 字段。
现在的需求是如果子图的entity valid 是true 就过滤掉(无论是Company 还是 Person), 但是在写的时候发现:
如何条件是 == false 就是一个空的,
如果是 != true 则是有结果的,这是为什么?

GET SUBGRAPH WITH PROP 2 STEPS FROM "2603d4a4b1f04ebd1435f8adf30cbc7a" BOTH Invest, Employ, Legal where $$.Company.valid  != true and $$.Person.valid != true  YIELD VERTICES as v, Edges as e

image

image

这个怎么理解?

valid可能为空?

这个例子的里面 !=true 出来的数据,都是false。
全图里面应该都是true/false 没有null 的情况

这个 WHERE $$.Company.valid == False 蕴涵着点的类型的限定,加上 AND 其实交集是空了,可惜现在不支持 OR。

所以如果是多点类型子图,似乎只能 GET SUBGRAPH 不过滤,再展开用管道去用 OR 过滤一下(不过感觉不好表达),不行用 match 吧

之所以过滤是因为这个filter 是下推了的。valid==true 的点,大概率是个超级节点,这个时候不过滤可能会超时查不出来,所以想用这个trick 去解决这个问题。
如果用 $$.Company.valid != true and $$Person.valid != true 能否满足需求的语意?

不用match 是因为 性能比较低,而且难以表达子图的含义

$$.Company.valid == False and $$.Person.valid ==False 的交集为什么是空。
如果是Person 类型,那么$$.Company 应该是null? 所以$$.Company.valid 应该是null,所以null and True 是null 的意思吗?

因为我感觉,现在 $$.Company.valid == False 这个条件蕴涵扫过的点点必须是 Company然后才是 valid 的条件 see:

(root@nebula) [basketballplayer]> get subgraph 2 steps from "player103" BOTH follow,serve WHERE $$.team.name > "A" yield vertices AS nodes
+--------------------------------------------------------------------------------------+
| nodes                                                                                |
+--------------------------------------------------------------------------------------+
| [("player103" :player{})]                                                            |
| [("team204" :team{}), ("team218" :team{}), ("team208" :team{}), ("team212" :team{})] |
+--------------------------------------------------------------------------------------+
Got 2 rows (time spent 16.202ms/146.02ms)

Fri, 01 Dec 2023 12:58:37 CST

(root@nebula) [basketballplayer]> get subgraph 2 steps from "player103" BOTH follow,serve WHERE $$.player.name > "A" yield vertices AS nodes

+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| nodes                                                                                                                                                                           |
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| [("player103" :player{})]                                                                                                                                                       |
| [("player114" :player{}), ("player102" :player{})]                                                                                                                              |
| [("player115" :player{}), ("player127" :player{}), ("player135" :player{}), ("player133" :player{}), ("player140" :player{}), ("player101" :player{}), ("player100" :player{})] |
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
Got 3 rows (time spent 14.54ms/129.430375ms)

1 个赞

那 $$.Company.valid != true and $$.Person.valid != true 这个会符合语意吗?

不对,用了$$.Company.valid != false and $$.Person.valid != false 发现返回的只有person, 并且这个字段为false

1 个赞

$$.Company.valid != false and $$.Person.valid != false 感觉可以呢

(root@nebula) [basketballplayer]> get subgraph 2 steps from "player103" BOTH follow,serve WHERE $$.player.name != "A" AND $$.team.name != "A" y+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| nodes                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| [("player103" :player{})]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| [("team204" :team{}), ("team218" :team{}), ("player114" :player{}), ("player102" :player{}), ("team208" :team{}), ("team212" :team{})]                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| [("player106" :player{}), ("player138" :player{}), ("team226" :team{}), ("player115" :player{}), ("player107" :player{}), ("player125" :player{}), ("player104" :player{}), ("team203" :team{}), ("player127" :player{}), ("player135" :player{}), ("player113" :player{}), ("player124" :player{}), ("player105" :player{}), ("player109" :player{}), ("player111" :player{}), ("player100" :player{}), ("player101" :player{}), ("player110" :player{}), ("team202" :team{}), ("player133" :player{}), ("player140" :player{}), ("player108" :player{}), ("player139" :player{}), ("player112" :player{})] |
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
Got 3 rows (time spent 16.086ms/114.041833ms)

Fri, 01 Dec 2023 14:05:17 CST

你用with prop 试试,我看了下,返回的结果里面是有valid == false 的,很奇怪,这个逻辑不知道怎么产生的。

是不是起点上的?

我这边好像是 ok 的,你那边有木有插入是 null / 但是 schema 里有 default 是 false 的问题?

(root@nebula) [basketballplayer]> get subgraph with prop 2 steps from "player103" BOTH follow,serve WHERE $$.player.name != "Kobe Bryant" AND $$.team.name != "Magic" yield vertices AS nodes
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| nodes                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| [("player103" :player{age: 32, name: "Rudy Gay"})]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| [("team204" :team{name: "Spurs"}), ("team218" :team{name: "Raptors"}), ("player114" :player{age: 39, name: "Tracy McGrady"}), ("player102" :player{age: 33, name: "LaMarcus Aldridge"}), ("team208" :team{name: "Kings"}), ("team212" :team{name: "Grizzlies"})]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| [("player106" :player{age: 25, name: "Kyle Anderson"}), ("player138" :player{age: 38, name: "Paul Gasol"}), ("player107" :player{age: 32, name: "Aron Baynes"}), ("player125" :player{age: 41, name: "Manu Ginobili"}), ("player104" :player{age: 32, name: "Marco Belinelli"}), ("team203" :team{name: "Trail Blazers"}), ("player127" :player{age: 42, name: "Vince Carter"}), ("player135" :player{age: 28, name: "Damian Lillard"}), ("player113" :player{age: 29, name: "Dejounte Murray"}), ("player124" :player{age: 33, name: "Rajon Rondo"}), ("player105" :player{age: 31, name: "Danny Green"}), ("player109" :player{age: 34, name: "Tiago Splitter"}), ("player111" :player{age: 38, name: "David West"}), ("player100" :player{age: 42, name: "Tim Duncan"}), ("player101" :player{age: 36, name: "Tony Parker"}), ("player110" :player{age: 27, name: "Cory Joseph"}), ("team202" :team{name: "Rockets"}), ("player133" :player{age: 38, name: "Yao Ming"}), ("player140" :player{age: 46, name: "Grant Hill"}), ("player108" :player{age: 36, name: "Boris Diaw"}), ("player139" :player{age: 34, name: "Marc Gasol"}), ("player112" :player{age: 29, name: "Jonathon Simmons"})] |
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
Got 3 rows (time spent 14.571ms/149.043834ms)

(root@nebula) [basketballplayer]> get subgraph with prop 2 steps from "player103" BOTH follow,serve yield vertices AS nodes

+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| nodes                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| [("player103" :player{age: 32, name: "Rudy Gay"})]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| [("team204" :team{name: "Spurs"}), ("team218" :team{name: "Raptors"}), ("player114" :player{age: 39, name: "Tracy McGrady"}), ("player102" :player{age: 33, name: "LaMarcus Aldridge"}), ("team208" :team{name: "Kings"}), ("team212" :team{name: "Grizzlies"})]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| [("player106" :player{age: 25, name: "Kyle Anderson"}), ("player138" :player{age: 38, name: "Paul Gasol"}), ("team226" :team{name: "Magic"}), ("player115" :player{age: 40, name: "Kobe Bryant"}), ("player107" :player{age: 32, name: "Aron Baynes"}), ("player125" :player{age: 41, name: "Manu Ginobili"}), ("player104" :player{age: 32, name: "Marco Belinelli"}), ("team203" :team{name: "Trail Blazers"}), ("player127" :player{age: 42, name: "Vince Carter"}), ("player135" :player{age: 28, name: "Damian Lillard"}), ("player113" :player{age: 29, name: "Dejounte Murray"}), ("player124" :player{age: 33, name: "Rajon Rondo"}), ("player105" :player{age: 31, name: "Danny Green"}), ("player109" :player{age: 34, name: "Tiago Splitter"}), ("player111" :player{age: 38, name: "David West"}), ("player100" :player{age: 42, name: "Tim Duncan"}), ("player101" :player{age: 36, name: "Tony Parker"}), ("player110" :player{age: 27, name: "Cory Joseph"}), ("team202" :team{name: "Rockets"}), ("player133" :player{age: 38, name: "Yao Ming"}), ("player140" :player{age: 46, name: "Grant Hill"}), ("player108" :player{age: 36, name: "Boris Diaw"}), ("player139" :player{age: 34, name: "Marc Gasol"}), ("player112" :player{age: 29, name: "Jonathon Simmons"})] |
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
Got 3 rows (time spent 13.921ms/207.451ms)

又测了几遍,可能之前看错了,起点id 的属性确实为false。

ok,那就 OK 了

此话题已在最后回复的 30 天后被自动关闭。不再允许新回复。