我正在使用最新版本的ArangoDb,但出现问题。我有两个收藏夹:
国家(这是文档集合)和距离(这是具有诸如_from,_to,distance之类的键的边集合)。
我如何通过AQL获得有关Country.Continent = 'Europe'
所在国家/地区与边距之间的距离的所有信息?
SQL将会是这样:
Select * from Country c, Distance d where c.Continent = 'Europe'
谢谢。
我最近一直在从事一个项目,并开始使用ArangoDB,因此希望能对您有所帮助。
我从Arango和AQL文档的以下链接中得到了一些启发,:
请参阅下面的AQL查询,请告诉我是否有帮助。您可以将FILTER上的“欧洲”部分替换为@Continent,这将使您可以根据需要动态指定它。
FOR country IN Country
FILTER country.Continent == 'Europe'
FOR vertex, edge, path
IN OUTBOUND country Distance
RETURN path
这将为我带来以下结果。我刚刚创建了一些具有2条将国家联系在一起的测试集。我在“ FOR”部分中包含了顶点,边以及查询路径,因此欢迎您在最后使用“ RETURN”部分,方法是替换顶点或边并查看产生的结果为了你。
[
{
"edges": [
{
"_key": "67168",
"_id": "Distance/67168",
"_from": "Country/67057",
"_to": "Country/67094",
"_rev": "_aecXk7---_",
"Distance": 5
}
],
"vertices": [
{
"_key": "67057",
"_id": "Country/67057",
"_rev": "_aecWJ0q--_",
"countryName": "UK",
"Continent": "Europe"
},
{
"_key": "67094",
"_id": "Country/67094",
"_rev": "_aecWZhi--_",
"countryName": "Italy",
"Continent": "Europe"
}
]
},
{
"edges": [
{
"_key": "67222",
"_id": "Distance/67222",
"_from": "Country/67057",
"_to": "Country/67113",
"_rev": "_aecYB9---_",
"Distance": 10
}
],
"vertices": [
{
"_key": "67057",
"_id": "Country/67057",
"_rev": "_aecWJ0q--_",
"countryName": "UK",
"Continent": "Europe"
},
{
"_key": "67113",
"_id": "Country/67113",
"_rev": "_aecWmEy--_",
"countryName": "Spain",
"Continent": "Europe"
}
]
}
]
例如,如果您将'RETURN path'部分替换为'RETURN edge',则仅根据需要检索边缘,如下所示:
[
{
"_key": "67168",
"_id": "Distance/67168",
"_from": "Country/67057",
"_to": "Country/67094",
"_rev": "_aecXk7---_",
"Distance": 5
},
{
"_key": "67222",
"_id": "Distance/67222",
"_from": "Country/67057",
"_to": "Country/67113",
"_rev": "_aecYB9---_",
"Distance": 10
}
]