嗨,我的有效载荷如下:
{
"Id": "3",
"List": {
"Steps": [
{
"StepId": "1",
"stepDesc1": [
{
"sortNo": "2",
"description": "ABC"
},
{
"sortNo": "1",
"description": "XYZ"
}
],
"stepDesc2": [
{
"sortNo": "2",
"description": "AAA"
},
{
"sortNo": "1",
"description": "BBB"
}
]
},
{
"StepId": "2",
"stepDesc1": [
{
"sortNo": "2",
"description": "CCC"
},
{
"sortNo": "1",
"description": "DDD"
}
],
"stepDesc2": [
{
"sortNo": "2",
"description": "EEE"
},
{
"sortNo": "1",
"description": "FFF"
}
]
}
]
}
}
我想按Id和StepId进行过滤,按SortNo排序并返回数据
我已经在下面的查询中使用ID和StepId进行过滤
FOR test IN test_data
FILTER test.Id=='3'
FILTER '1' IN test.List.Steps[*].StepId
SORT test.List.Steps[*].stepDesc1.sortNo ASC
RETURN test.Steps
但是第二个过滤器条件不起作用,并向我返回与ID 3相对应的所有步骤。对于我来说,它应该返回到o / p以下
{
"StepId": "1",
"stepDesc1": [
{
"sortNo": "2",
"description": "ABC"
},
{
"sortNo": "1",
"description": "XYZ"
}
],
"stepDesc2": [
{
"sortNo": "2",
"description": "AAA"
},
{
"sortNo": "1",
"description": "BBB"
}
]
}
任何人都可以帮助我解决问题
答案 0 :(得分:0)
我相信您正在寻找的是这样的东西。因为您要应用的第二个FILTER是真实的1
确实在数组中,但是AQL并不排除2
。只是说1
必须存在。如果循环嵌套数组,则可以使用==
。希望这可以帮助。
FOR test IN test_data
FILTER test.Id == '3'
FOR step IN test.List.Steps
FILTER step.StepId == '1'
SORT step[*].stepDesc1.sortNo ASC
RETURN step