find path 点过滤

提问参考模版:

  • nebula 版本:v3.4.1
  • 部署方式: 分布式
  • 安装方式:RPM
  • 是否上生产环境:Y
  • 硬件信息
    • 磁盘( 推荐使用 SSD)
    • CPU、内存信息
  • 问题的具体描述
  • 相关的 meta / storage / graph info 日志信息(尽量使用文本形式方便检索)

想要在路径查找后根据点属性过滤,原始语句是

find shortest path with prop from -980682560400423797 to -2886766351330904521  OVER Legal,ActualController,HisLegal BIDIRECT upto 2 steps YIELD path AS p

看到论坛有 YIELD $-.p where "vertexid" in [n in nodes($-.p) | id(n)] 的写法
想问问 如果在路径中是Company,Person 两种点,想过滤name 属性不包含了敏感词如xxx
尝试 下面报错了, 请问这个该怎么改写

find shortest path with prop from -980682560400423797 to -2886766351330904521  OVER Legal,ActualController,HisLegal BIDIRECT upto 2 steps YIELD path AS p | YIELD $-.p where "xxx" not in [n in nodes($-.p) | n.Company.name]

实践编写语句时, | 之后的变量最好换一个变量名。
可以改成这样,以官网示例数据集 “权利的游戏” 为例

FIND SHORTEST PATH WITH PROP FROM "Daenerys-Targaryen" to "Jon-Arryn" \
OVER * BIDIRECT UPTO 5 STEPS \
YIELD path AS p | \
YIELD $-.p AS pp \
WHERE 2 NOT IN  [ n in NODES($-.p) | n.person.book ]
1 个赞

感谢。思考了下,我表述的不够准确。
是n.Company.name 不能包含某些关键词,in, not in 的语义应该是完全匹配,我这个是 n.Company.name or n.Person.name not contains “比特币”。
这样得话,应该怎么写呢

可以使用 WHERE … OR

试试:WHERE [ n in NODES($-.p) | properties(n).name ] not contains “比特币”

find shortest path with prop from -980682560400423797 to -2886766351330904521  OVER Legal,ActualController,HisLegal BIDIRECT upto 2 steps YIELD path AS p | YIELD $-.p as pp where [n in nodes($-.p) | properties(n).name] not contains "比特币"

“message”: “Failed to evaluate condition: ([__VAR_0 IN nodes($-.p) | properties($__VAR_0).name] NOT CONTAINS "比特币"). For boolean conditions, please write in their full forms like == <true/false> or IS [NOT] NULL.”

这个写法报错

没太懂怎么写, WHERE 2 NOT IN [ n in NODES($-.p) | n.person.book ] 这个没有contains 的语义

我明白你的意思了,可以这么写

FIND SHORTEST PATH WITH PROP FROM "Daenerys-Targaryen" to "Jon-Arryn" \
OVER * BIDIRECT UPTO 5 STEPS \
YIELD path AS p | \
YIELD $-.p AS pp \
WHERE NOT ANY ( a IN [ n in NODES($-.p) | n.person.name ] WHERE a CONTAINS "ZZZZ" ) 

另外, LIST 可以执行 [ ] + [ ] 操作

3 个赞
FIND all PATH with prop FROM "player100" to "team203" OVER * UPTO 5 STEPS YIELD path AS p1 | yield reduce(filter=false,n in nodes($-.p1)|filter or n.player.name contains "Manu" or n.team.name contains "Trail") as filter,$-.p1 as p2 | yield $-.p2 where $-.filter != true

也可以试试这样的

感谢

find shortest path with prop from -980682560400423797 to -2886766351330904521  OVER Legal,ActualController,HisLegal BIDIRECT upto 2 steps YIELD path AS p | YIELD $-.p as pp WHERE NOT ANY ( a IN [ n in NODES($-.p) | properties(n).name] WHERE a CONTAINS "比特币称" ) 

用了这个,因为entity 可能是Company 或者 Person, 用了 properteis(n) 代替了 n.Company.name or n.Person.name。
测试了两个,语义应该是符合的。

2 个赞

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