[英]get common elements from a result which consists of more than 1 array in arangodb
I want to fetch common elements from multiple arrays. 我想从多个数组中获取常见元素。 The no. 没有 of arrays resulted would keep changing depending upon the no. 数组的结果将根据否不断变化。 of tags in array a[]. 数组a []中的标签。
As a first step, my query and result I get is as shown below: 第一步,我得到的查询和结果如下所示:
let a=["Men","Women","Accessories"]
let c=(for i in a
Let d=Concat("Tags/",i)
return d)
for i in c
let m=(for y in outbound i TC
return y._key)
return m
and result I get is: 我得到的结果是:
[
[
"C1",
"C5",
"C7",
"C3"
],
[
"C2",
"C5",
"C6",
"C4"
],
[
"C7",
"C5",
"C6"
]
]
From this result, I want only common element as a result ie "C5" (here). 从这个结果中,我只想要一个公共元素,即“ C5”(此处)。
How can I get that? 我该怎么办?
This question has also been asked and answered on github . 这个问题也在github上被问到并回答了。
The function INTERSECTION() returns the intersection of all specified arrays and APPLY() is used to pass a dynamic amount of nested arrays. 函数INTERSECTION()返回所有指定数组的交集,而APPLY()用于传递动态数量的嵌套数组。
The query 查询
let D = [["C1","C5","C7","C3"],["C2","C5","C6","C4"],["C7","C5","C6"]]
RETURN APPLY("INTERSECTION", D)
results in: 结果是:
[
[
"C5"
]
]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.