Intersect two traversals in ArangoDB

醉酒当歌 提交于 2019-12-24 11:13:36

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!