Parameters, Value
Array Intersection function calculates the common elements of two arrays and returns them as array, i.e. returns the intersection of the two arrays (repeated elements are allowed within the arrays).
If arrays are not homologous: when used in WITH,
intersection()
will first make a Cartesian Product Combination of all columns and its homologous columns before calculation; when used in RETURN,intersection()
will trim all columns and their homologous columns before calculation.
Syntax:
- Format: intersection(
<array1>
,<array2>
) - Parameters: see table below
- Value: ARRAY
Common Usage
Example: find the common neighbors of Card CA001 and CA002, and return as array
khop().src({_id == "CA001"}).depth(1) as n1
khop().src({_id == "CA002"}).depth(1) as n2
with collect(n1) as a1, collect(n2) as a2
return intersection(a1, a2)