如何在ArangoDB中检查顶点匹配

f4t66c6m  于 2022-12-09  发布在  Go
关注(0)|答案(1)|浏览(167)

我已经在ArangoDB中创建了两个集合,一个文档集合“Node”和一个边缘集合“Path”,我所有的节点都有一个name属性,并通过边缘连接。
我的遍历具有可变深度1..10,它将找到以下路径:

start - decide
start - decide - execute1
start - decide - execute2
start - decide - execute1 - error
start - decide - execute2 - end
start - decide - execute1 - execute2 - end
start - decide - execute1 - execute2 - error
start - decide - execute2 - execute3 - end

我尝试了下面的查询来查找以结束节点或错误节点结束的路径:

FOR v, e, p IN 1..10 OUTBOUND 'Node/start_0' Path     
OPTIONS { bfs: true}     
FILTER (v.name == "end" OR v.name == "error")     
RETURN CONCAT_SEPARATOR(' - ', p.vertices[*].name)

它给我以下4个结果

[
    start - decide - execute1 - error
    start - decide - execute2 - end
    start - decide - execute1 - execute2 - end
    start - decide - execute1 - execute2 - error
    start - decide - execute2 - execute3 - end
]

这里我想做一个额外的模式匹配检查,我想列出结果,有特定的顺序,在他们的顶点。
我想列出其中包含序列decide execute1 execute2的结果,即,我的结果应如下所示:

[
     start - decide - execute1 - execute2 - end
     start - decide - execute1 - execute2 - error 
     ]

我尝试将以下筛选条件添加到查询中,但不起作用

FILTER LIKE(p.vertices[*].name, "%decide - execute1 - execute2%", true)

有人能帮我吗

idfiyjo8

idfiyjo81#

我相信,如果您将主查询移动到子查询中,然后再应用过滤器,这应该会起作用,例如:

FOR path IN (
    FOR v, e, p IN 1..10 OUTBOUND 'Node/start_0' Path     
    OPTIONS { bfs: true}     
    FILTER (v.name == "end" OR v.name == "error")     
    RETURN CONCAT_SEPARATOR(' - ', p.vertices[*].name)
)
FILTER LIKE(path, "%decide - execute1 - execute2%", true)
RETURN path

相关问题