如何在ArangoDB AQL中进行图形联合和相交

时间:2019-05-10 05:40:33

标签: graph arangodb aql

我们有一个图形模型(不是数据),如下图所示:

enter image description here

存储数据的实际图形只有一个edge collection和一个countries -> cities -> users -> like songs -> read books

如何对一个顶点上的多路径结果进行并集或相交查询:

return all paths that each user has at least one path on any branch

usa -> chicago -> john -> book-1 (accepted)
usa -> chicago -> john -> song-1 (accepted)

germany -> cologne -> john -> book-1 (accepted)

关于用户顶点的联合查询:

return all paths that each user has at least one path on each branch

usa -> chicago -> john -> book-1 (accepted)
usa -> chicago -> john -> song-1 (accepted)

germany -> cologne -> john -> book-1 (not accepted)

在用户顶点上相交查询:

for vertex in Vertex
for v,e,p in 1..3 any vertex._id graph 'DataGraph'
OPTIONS {bfs: true, uniqueVertices: 'global'}
FILTER

(
p.edges[0].edgeCollectionCode == 'locatedin'
and p.edges[1].edgeCollectionCode == 'livein'
and p.edges[2].edgeCollectionCode == 'read'
and length(p.edges)==3
)
||
(
p.edges[0].edgeCollectionCode == 'locatedin'
and p.edges[1].edgeCollectionCode == 'livein'
and p.edges[2].edgeCollectionCode == 'like'
and length(p.edges)==3
)

return p

关于相交,我们需要复杂的相交,其中我们具有相交的层次结构,其中顶点上的每个相交将沿路径上另一个顶点上另一个相交的结果进行运算。

关于工会,我想出了这个查询,这是在AQL中进行工会的正确方法:

{{1}}

0 个答案:

没有答案