Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
arangodb中数组内的筛选器不工作_Arangodb_Aql - Fatal编程技术网

arangodb中数组内的筛选器不工作

arangodb中数组内的筛选器不工作,arangodb,aql,Arangodb,Aql,我正在试着解决第20题。数据集是 Q20.编写MongoDB查询,查找得分不超过10分的餐厅的餐厅Id、名称、行政区和菜肴 我正在尝试以下方法,但我可以看到,我得到的结果是餐馆的分数为[2,6,10,9,14]和[8,23,12,12]。所以我知道这不可能是对的 for r in restaraunts for g in r.grades filter g.score <=10 return distinct {ID:r.restaurant

我正在试着解决第20题。数据集是

Q20.编写MongoDB查询,查找得分不超过10分的餐厅的餐厅Id、名称、行政区和菜肴

我正在尝试以下方法,但我可以看到,我得到的结果是餐馆的分数为[2,6,10,9,14]和[8,23,12,12]。所以我知道这不可能是对的

for r in restaraunts    
    for g in r.grades
        filter g.score <=10
        return distinct {ID:r.restaurant_id,name:r.name,borough:r.borough,cuisine:r.cuisine,score:r.grades[*].score}
    
用于餐厅中的r
对于r级中的g
过滤g.score使用
MAX()
函数确定要过滤的值:

for r in restaurants    
    LET score = MAX(r.grades[*].score)
    filter score <=10
    return distinct {ID:r.restaurant_id,name:r.name,borough:r.borough,cuisine:r.cuisine,score:score}

非常感谢。这真的很有帮助。这是一个精致而高效的解决方案!
for r in restaurants    
    LET score = MAX(r.grades[*].score)
    filter score <=10
    return distinct {ID:r.restaurant_id,name:r.name,borough:r.borough,cuisine:r.cuisine,score:score}
LET r = {'grades': [ {score: 5}, {score: 7}, {score: 15} ] }
RETURN MAX(r.grades[*].score)