如何查询连接到 Arangodb 图中多个节点的节点
How to query for a node that is connected to multiple nodes in Arango DB graph
我有一个图表,其中包含两种类型的节点:景点和酒店。
我想做的是查询被三个景点包围的酒店。我现在(下面)的查询给出了至少连接到一个景点的酒店。
FOR document IN Attraction
FOR vertex, edge, path IN 1..2 OUTBOUND document GRAPH "LondonAttractionDB"
FILTER path.vertices[0].entityTypes[0] == "Attraction" OR path.vertices[0].entityTypes[0] == "Attraction" OR path.vertices[0].entityTypes[0] == "Attraction"
FILTER path.vertices[1].entityTypes[0] == "Hotel"
FOR prop4 IN path.edges[0].properties
FILTER prop4.name == "name" AND prop4.value == "Food_and_beverage_location"
OR prop4.name == "name" AND prop4.value == "Food_and_beverage_location"
OR prop4.name == "name" AND prop4.value == "Accommodation_location"
RETURN DISTINCT path
结果如下。 (橙色 - 酒店,绿色 - 景点)
如何在圆圈内显示结果? (恰好与三个景点相连的酒店)
非常感谢任何帮助。
如果没有数据集(文档结构和集合)的详细信息,很难回答,但根据您的示例查询和描述,我会使用不同的方法:
- 查看所有文档(景点和酒店似乎位于同一个集合中)
- 按酒店类型过滤
- 对于每个酒店节点,获取具有传入边的邻居
- 按吸引力类型过滤这些节点
- 计算酒店有多少个节点
- Return 正好有三个相连景点的酒店
FOR hotel IN Attraction
FILTER doc.entityTypes[0] == "Hotel"
LET attractions = (
FOR vertex IN 1..1 INBOUND hotel GRAPH "LondonAttractionDB"
FILTER vertex.entityTypes[0] == "Attraction"
RETURN 1
)
FILTER LENGTH(attractions) == 3
RETURN hotel
我有一个图表,其中包含两种类型的节点:景点和酒店。
我想做的是查询被三个景点包围的酒店。我现在(下面)的查询给出了至少连接到一个景点的酒店。
FOR document IN Attraction
FOR vertex, edge, path IN 1..2 OUTBOUND document GRAPH "LondonAttractionDB"
FILTER path.vertices[0].entityTypes[0] == "Attraction" OR path.vertices[0].entityTypes[0] == "Attraction" OR path.vertices[0].entityTypes[0] == "Attraction"
FILTER path.vertices[1].entityTypes[0] == "Hotel"
FOR prop4 IN path.edges[0].properties
FILTER prop4.name == "name" AND prop4.value == "Food_and_beverage_location"
OR prop4.name == "name" AND prop4.value == "Food_and_beverage_location"
OR prop4.name == "name" AND prop4.value == "Accommodation_location"
RETURN DISTINCT path
结果如下。 (橙色 - 酒店,绿色 - 景点)
如何在圆圈内显示结果? (恰好与三个景点相连的酒店)
非常感谢任何帮助。
如果没有数据集(文档结构和集合)的详细信息,很难回答,但根据您的示例查询和描述,我会使用不同的方法:
- 查看所有文档(景点和酒店似乎位于同一个集合中)
- 按酒店类型过滤
- 对于每个酒店节点,获取具有传入边的邻居
- 按吸引力类型过滤这些节点
- 计算酒店有多少个节点
- Return 正好有三个相连景点的酒店
FOR hotel IN Attraction
FILTER doc.entityTypes[0] == "Hotel"
LET attractions = (
FOR vertex IN 1..1 INBOUND hotel GRAPH "LondonAttractionDB"
FILTER vertex.entityTypes[0] == "Attraction"
RETURN 1
)
FILTER LENGTH(attractions) == 3
RETURN hotel