Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with where condition filtering not taking effect. #5835

Closed
AntarcticPresident opened this issue Mar 12, 2024 · 9 comments
Closed

Issue with where condition filtering not taking effect. #5835

AntarcticPresident opened this issue Mar 12, 2024 · 9 comments
Labels
type/question Type: question about the product

Comments

@AntarcticPresident
Copy link

AntarcticPresident commented Mar 12, 2024

GET SUBGRAPH with prop 5 STEPS FROM "A" both relationship where $$.friend.name != "name1" and $$.friend.type == "type" YIELD EDGES AS relationships;

这是查询语句,我想查A这个人通过relationship这个关系上5步以内的联系人。
我的vertex不仅有friend,还有workmate、boss。就是用relationship这个edgetype连接了friend、workmate、boss这三种vertex。
问题是:
上面那个语句的返回结果,只有friend,没有boss或者workmate。我感觉是$$.friend.type == "type"这个条件导致返回结果必须满足friend的type为type,boss和workmate因为没有type这个字段,就没有返回。
如何能让boss和workmate出现在返回值里面?

@QingZ11 QingZ11 added the type/question Type: question about the product label Mar 12, 2024
@QingZ11 QingZ11 changed the title 查询语句中where的效果与预期不符 Issue with where condition filtering not taking effect. Mar 12, 2024
@QingZ11
Copy link
Contributor

QingZ11 commented Mar 12, 2024

$$.friend.name != "name1" and $$.friend.type == "type"

因为你这里指定了 tag 的类型是 friend 自然是结果只会出来 friend 相关的。你的 friend、workmate、boss 是不是都是一个点类型(tag)?如果是的话,你可以试试这个条件过滤改成这个

properties($$).name != "name1" and properties($$).type == "type" 

看看可以不

@AntarcticPresident
Copy link
Author

这三个点不是一个类型的。
我本意是想通过过滤这一组路径中的点,来过滤路径。结果加上了条件,就把返回范围固定在具有这个tag的点里面了。
按你的说法,我这种想法是实现不了了么。。。

@QingZ11
Copy link
Contributor

QingZ11 commented Mar 19, 2024

不不,我才疏学浅。问问大佬们咋看 @Salieri-004 这题你会么?

@Salieri-004
Copy link
Contributor

GET SUBGRAPH不支持or的过滤条件,match可以支持类似的写法,比如
match (u)-[e*1..5]->(v:team) where v.player.age > 1 or v.team.name is not null return u,v limit 100

@AntarcticPresident
Copy link
Author

谢谢,了解了~

@AntarcticPresident
Copy link
Author

GET SUBGRAPH不支持or的过滤条件,match可以支持类似的写法,比如 match (u)-[e*1..5]->(v:team) where v.player.age > 1 or v.team.name is not null return u,v limit 100

这个有个缺点,图模式指定了起点,如果我只能确定第二跳的条件,然后第一跳可能有也可能没有,这怎么办?

@Salieri-004
Copy link
Contributor

GET SUBGRAPH不支持or的过滤条件,match可以支持类似的写法,比如 match (u)-[e*1..5]->(v:team) where v.player.age > 1 or v.team.name is not null return u,v limit 100

这个有个缺点,图模式指定了起点,如果我只能确定第二跳的条件,然后第一跳可能有也可能没有,这怎么办?

可以参考https://docs.nebula-graph.com.cn/3.6.0/3.ngql-guide/7.general-query-statements/2.match/
image
通过列表相关的函数和表达式进行描述

@AntarcticPresident
Copy link
Author

AntarcticPresident commented Mar 21, 2024

GET SUBGRAPH不支持or的过滤条件,match可以支持类似的写法,比如 match (u)-[e*1..5]->(v:team) where v.player.age > 1 or v.team.name is not null return u,v limit 100

这个有个缺点,图模式指定了起点,如果我只能确定第二跳的条件,然后第一跳可能有也可能没有,这怎么办?

可以参考https://docs.nebula-graph.com.cn/3.6.0/3.ngql-guide/7.general-query-statements/2.match/image 通过列表相关的函数和表达式进行描述

可能我没表述清楚。
比方完整链路是A->B->C->D,可能存在某一链路是B->C->D。我想把这两种都找出来。

@AntarcticPresident
Copy link
Author

GET SUBGRAPH不支持or的过滤条件,match可以支持类似的写法,比如 match (u)-[e*1..5]->(v:team) where v.player.age > 1 or v.team.name is not null return u,v limit 100

这个有个缺点,图模式指定了起点,如果我只能确定第二跳的条件,然后第一跳可能有也可能没有,这怎么办?

可以参考https://docs.nebula-graph.com.cn/3.6.0/3.ngql-guide/7.general-query-statements/2.match/image 通过列表相关的函数和表达式进行描述

可能我没表述清楚。 比方完整链路是A->B->C->D,可能存在某一链路是B->C->D。我想把这两种都找出来。

找到方法了,可以用optional match做补充

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/question Type: question about the product
Projects
None yet
Development

No branches or pull requests

3 participants