arangodb - Arangodb AQL Query for multiple edge definitions
问题描述
I am new to graph databases and arangodb too. I try to query a graph with different edge definitions and didn't find any example for this. A query to get a result for one edge I found.
FOR p IN person FOR vx, ex, px IN ANY p GRAPH "test" FILTER vx.brand == "BMW" RETURN DISTINCT p
For example: I have vertices "person", "car" and "house" and edges "has_car" (person->car) and "lives_in" (person->house). To try out I created three graphs. One for each edge definition and one with both edge definitions.
My question: What is the right way to query:
- Persons who have a "BMW" and live in a "Castle"
- Persons who live in a "Skyscraper" and don't have a car
- Persons who live in a "Skyscraper" and don't have a "BMW"
Thanks.
解决方案
如果你从头开始呢?这样你就可以检查整个路径。
以下是从宝马汽车开始的示例(第一个问题)
for car in Car filter car.brand=="BMW"
for v,e,p in 0..2 any car._id graph 'test'
filter p.edges[0]!=null && is_same_collection('has_car', p.edges[0])
&& p.vertices[1]!=null && is_same_collection('Person', p.vertices[1])
&& p.edges[1]!=null && is_same_collection('lives_in', p.edges[1])
&& p.vertices[2]!=null && p.vertices[2].house=="Castle"
return distinct(p.vertices[1])
推荐阅读
- ruby-on-rails - 为什么允许非管理员用户访问我在 Rails 应用程序中的索引页面?(设计宝石)
- python - 为什么curve_fit不会收敛到beta函数拟合?
- angular - 使用自定义 TS 装饰器的组件方法中未定义角服务
- gridview - 使用 yii2 gridview 在组内排序
- docker - 如何在覆盖模式下从 docker swarm 访问主机本地网络?
- python - 循环遍历数据帧并生成随机数据帧
- azure - 如何在 VSTS 的 CI 管道中设置此规则
- excel - 如何更改复制表的名称(在复制粘贴方法期间)?
- c# - 使用没有 SendKeys 的 C# selenium 上传文件
- php - 如何在 php 中集成 Gmail API