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

Why do the values ​​returned by yield affect each other #5495

Closed
T0L0ve opened this issue Apr 13, 2023 · 1 comment
Closed

Why do the values ​​returned by yield affect each other #5495

T0L0ve opened this issue Apr 13, 2023 · 1 comment
Assignees
Labels
affects/none PR/issue: this bug affects none version. process/fixed Process of bug severity/none Severity of bug type/bug Type: something is unexpected

Comments

@T0L0ve
Copy link

T0L0ve commented Apr 13, 2023

General Question
写了个查询语句

go from "1" over withgenres YIELD dst(edge) as g,src(edge) as m 
|go from $-.g over withgenres reversely yield src(edge) as recomm , $-.m as m,$-.g as g 
|group by $-.m,$-.recomm YIELD $-.m as m,$-.recomm as recomm,tofloat(size(COLLECT($-.g))) as size 
|go from $-.m over withgenres YIELD dst(edge) as g,src(edge) as m,$-.recomm as recomm,$-.size as size
|group by $-.m,$-.recomm,$-.size YIELD $-.recomm as recomm,COLLECT($-.g) as set_a,$-.size as size
|go from $-.recomm over * YIELD dst(edge) as g,$-.recomm as recomm ,$-.size as size,$-.set_a as set_a
|group by $-.recomm ,$-.size,$-.set_a YIELD $-.recomm as recomm,$-.set_a as set_a,$-.size as size ,$-.size/size(toSet($-.set_a + COLLECT($-.g))) AS jaccard
|yield  $-.recomm as recomm,$-.jaccard as jaccard
|order by $-.jaccard DESC

结果是这样的
image
但我将yield 中的$-.set_a as set_a删除后就无法计算出jaccard值
image
这是删除后的结果
image
同理删除边上的size也影响了结果输出。

另外我想查询与某一部电影包含相同电影类型的电影,并且将结果按jaccard相似度排序,但我现在的查询语句需要花费0.45秒才能完成查询。如果是仅查询某一部电影包含相同电影类型的电影,也就是查询语句的前两句仅消耗0.08秒,所以我想知道该怎么优化我写的计算jaccard相似度的部分,或者是不是有什么函数能让结果直接按照相似度排序。

@Sophie-Xie Sophie-Xie changed the title yield 返回的值为什么会互相影响 Why do the values ​​returned by yield affect each other Apr 17, 2023
@Sophie-Xie Sophie-Xie added the type/bug Type: something is unexpected label Apr 19, 2023
@github-actions github-actions bot added affects/none PR/issue: this bug affects none version. severity/none Severity of bug labels Apr 19, 2023
@xtcyclist
Copy link
Contributor

This issue could not be reproduced in the latest version. Please try upgrading to the latest version and check again.

(root@nebula) [nba]> go from "Tim Duncan" over * yield properties($^).age as a, properties($$).age as b | group by $-.a, $-.b yield 1 as x, abs($-.a + $-.b) as c | yield $-.x, $-.c as c | order by $-.c
+------+----------+
| $-.x | c        |
+------+----------+
| 1    | 73       |
| 1    | 75       |
| 1    | 78       |
| 1    | 83       |
| 1    | __NULL__ |
+------+----------+
Got 5 rows (time spent 5415/5782 us)

You could write your own UDF to implement jaccard or check this: https://docs.nebula-graph.com.cn/3.4.0/graph-computing/algorithm-description/#jaccard.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects/none PR/issue: this bug affects none version. process/fixed Process of bug severity/none Severity of bug type/bug Type: something is unexpected
Projects
None yet
Development

No branches or pull requests

3 participants