问题
I'm trying to understand how to intersect two results in ArangoDB and my scenario looks like this.
I can easily find users living in Spain, Island or Europe with the query:
FOR x IN 1..3 INBOUND "places/Europe" situedIn,livesIn
FILTER IS_SAME_COLLECTION('users',x)
return x
What I want to understand is the best way to extend the search capabilities to include Profession:
Example:
- Return all Police in Spain (returns [A])
- Return all Police in Europe (returns [A])
- Return all Legal in Europe (returns [A,B])
Thankful for any help
回答1:
After some more searching the answer is INTERSECTION
FOR a IN INTERSECTION (
(FOR x IN 1..3 INBOUND "places/Europe" situedIn
FOR p IN INBOUND x livesIn
return p),
(FOR x IN 1..3 INBOUND "profession/Medical" specializes
FOR p IN INBOUND x worksWith
return p)
) RETURN a
回答2:
The _commonNeighbors
function may be what you're looking for. It returns the intersection between two sets of vertices.
https://docs.arangodb.com/3.0.10/Manual/Graphs/GeneralGraphs/Functions.html#commonneighbors
来源:https://stackoverflow.com/questions/39979189/intersect-two-traversals-in-arangodb