Reputation: 499
I have created two collections in ArangoDB, a document collection "Node" and an edge collection "Path". All my nodes have a name attribute and are connected by edges.
My traversal has a variable depth of 1..10, which will find the followings paths:
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
I tried below query to find paths that end with an end or error node:
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)
It gives me below 4 Results
[
start - decide - execute1 - error
start - decide - execute2 - end
start - decide - execute1 - execute2 - end
start - decide - execute1 - execute2 - error
start - decide - execute2 - execute3 - end
]
Here i want to do a additional pattern matching check, I want to list results that has particular sequence of vertex in them.
I want to list the result that has sequence decide execute1 execute2
in them
i.e., My result should be as given below:
[
start - decide - execute1 - execute2 - end
start - decide - execute1 - execute2 - error
]
I tried adding below filter condition to my query but it didnot work
FILTER LIKE(p.vertices[*].name, "%decide - execute1 - execute2%", true)
Can Someone help me on this
Upvotes: 1
Views: 212
Reputation: 3906
I believe this should work if you move the main query into a subquery, and then apply the filter afterwards, e.g. something like:
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
Upvotes: 0