我有一个包含两种类型节点的图表:景点和酒店。
我想要查询的是被三个景点包围的酒店。我现在(下面)的查询给出了至少连接到一个景点的酒店。
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
这给出了以下结果。 (橙色 - 酒店,绿色 - 景点)
如何在圆圈中显示结果? (酒店与三个景点相连)
非常感谢任何帮助。
答案 0 :(得分:2)
如果没有关于数据集(文档结构和集合)的详细信息,很难回答,但根据您的示例查询和描述,我会使用不同的方法:
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