简体   繁体   English

Arangodb AQL查询多个边缘定义

[英]Arangodb AQL Query for multiple edge definitions

I am new to graph databases and arangodb too. 我是图形数据库和arangodb的新手。 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). 例如:我有顶点“人”,“汽车”和“房屋”,以及边线“ has_car”(人->汽车)和“ lives_in”(人->房屋)。 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: 我的问题 :什么是正确的查询方式:

  1. Persons who have a "BMW" and live in a "Castle" 拥有“宝马”并住在“城堡”中的人
  2. Persons who live in a "Skyscraper" and don't have a car 居住在“摩天大楼”中且没有汽车的人
  3. Persons who live in a "Skyscraper" and don't have a "BMW" 居住在“摩天大楼”中但没有“宝马”的人

Thanks. 谢谢。

What if you started from an end? 如果您从头开始怎么办? That way you can check a whole path . 这样,您可以检查整个路径

for an example following is starting from a BMW car (for the first question) 以下是从宝马汽车开始的示例(第一个问题)

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])

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM