SELECT * from bucket b WHERE meta().id = 'PROFILE_LIST'
上面的查询给出以下结果,但是我还需要内部数组matchingProfile_应该以createdDate的排序顺序排列。可能吗?如果是,我必须对此查询进行哪些更改才能实现相同的目的?
[
{
"matchingProfile_": [
{
"createdDate": "2020-09-26T02:30:00",
"contactDetails_": {
"address_": {
"addressLine1_": "",
"addressLine2_": "",
"city_": ""
}
},
{
"createdDate": "2020-09-27T02:30:00",
"contactDetails_": {
"address_": {
"addressLine1_": "",
"addressLine2_": "",
"city_": ""
}
}
]
}
]
答案 0 :(得分:2)
使用子查询表达式可以按预期方式保留整个文档结构和排序数组(甚至使用完整的SQL功能)
SELECT b.*,
(SELECT RAW mp
FROM b.matchingProfile_ AS mp
ORDER BY mp.createdDate) AS matchingProfile_
FROM bucket AS b USE KEYS 'PROFILE_LIST';