已经新建的有原文索引,执行报错

我感觉你可以少写一层管道,参考:

(root@nebula) [basketballplayer]> lookup on player YIELD vertex AS v | yield $-.v.player.age AS age, $-.v.player.name AS name WHERE $-.v.player.name CONTAINS "s"
+-----+-------------------------+
| age | name                    |
+-----+-------------------------+
| 22  | "Ben Simmons"           |
| 29  | "Jonathon Simmons"      |
| 33  | "LaMarcus Aldridge"     |
| 25  | "Kyle Anderson"         |
| 27  | "Cory Joseph"           |
| 29  | "Klay Thompson"         |
| 38  | "Paul Gasol"            |
| 34  | "Marc Gasol"            |
| 32  | "Aron Baynes"           |
| 34  | "LeBron James"          |
| 29  | "James Harden"          |
| 36  | "Boris Diaw"            |
| 23  | "Kristaps Porzingis"    |
| 30  | "Russell Westbrook"     |
| 38  | "David West"            |
| 33  | "Chris Paul"            |
| 45  | "Jason Kidd"            |
| 24  | "Giannis Antetokounmpo" |
| 45  | "Steve Nash"            |
+-----+-------------------------+
Got 19 rows (time spent 2.514ms/32.561875ms)

再就是如果 v 里数据很多,返回只是很小一部分,在第一步就精确剔除掉不需要的会更优化一些

嗯,这种就需要得把条件也拼进去


这么写为啥这么耗时,用了5秒多

因为要把能加的 where 尽量放在第一步呀,我前边说了,那个决定了数据扫描的量,你这个是全扫描再过滤了。

一定要在第一个 lookup 的where 里尽量多加除了 contain 之外的条件,减少扫描数据量。

条件写在 yield 里是不得已的,能提前要提前

008075b78fe96e1d594c0526fa3970c
这个需求是根据这些属性,反推所有满足的点的数据,怎么实现

lookup on player WHERE <xxx这里加上所有除了 contains 之外的条件>
  YIELD vertex AS v | yield $-.v.player.age AS age, $-.v.player.name AS name WHERE $-.v.player.name CONTAINS "s"

1 个赞

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