[英]AQL: How to get back the path that all edges must have an property(array) and that array must have at least one certain value
Suppose I have an graph like this:假设我有这样的图表:
A---edge1---B property P [P1,P2] A---edge1---B 属性 P [P1,P2]
B---edge2---C property P [P2,P3] B---edge2---C 属性 P [P2,P3]
C---edge3---D property P [P2,P3] C---edge3---D 属性 P [P2,P3]
B---edge4---D property P [P1,P3] B---edge4---D 属性 P [P1,P3]
And each edge have an property P which is an array of string [P1,P2,P3].每条边都有一个属性 P,它是一个字符串数组 [P1,P2,P3]。 Each edge has their own value of P Now I would like to return all vertexes that:
每条边都有自己的 P 值现在我想返回所有顶点:
** **
For entity in entities
For v,e,p in Collection in 0..2 ANY entity
Filter //What should I do here? I tried p.edges[*].P[*] ANY =="P2"
Collect v._key into groups
return {key:v._key,group:groups} //Get the vertex that satisfy the condition
** **
p.edges[*].P[*]
is an array of arrays. p.edges[*].P[*]
是一个 arrays 的数组。 To get ANY ==
to compare array to individual element would require a flattened array, but then it cannot be determined whether each array has "P2"
.要让
ANY ==
将数组与单个元素进行比较,需要一个扁平数组,但无法确定每个数组是否具有"P2"
。
One of the following conditions should work however:但是,以下条件之一应该有效:
FILTER p.edges[* RETURN "P2" IN CURRENT.P] ALL == true
FILTER (FOR arr IN p.edges[*].P RETURN "P2" IN arr) ALL == true
FILTER LENGTH(p.edges[* FILTER "P2" IN CURRENT.P]) == LENGTH(p.edges)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.