Python 在AWS DocumentDB中筛选数组字段

Python 在AWS DocumentDB中筛选数组字段,python,pymongo,aws-documentdb,Python,Pymongo,Aws Documentdb,我正在尝试从我的DocumentDB中筛选帖子数据的注释字段。下面是数据的结构 { _id: <objectidgoeshere>, author: { userId: 2, handleName: "VladimirPutin" } postBody: "Lorem ipsum dolor amet", comments: [ { commentBody: "Anothe

我正在尝试从我的
DocumentDB
中筛选帖子数据的注释字段。下面是数据的结构

{
    _id: <objectidgoeshere>,
    author: {
        userId: 2,
        handleName: "VladimirPutin"
    }
    postBody: "Lorem ipsum dolor amet",
    comments: [
        {
            commentBody: "Another lorem ipsum",
            author: {
                user_id: 4,
                handleName: "JohnDoe"
            }
            replies: [
                {
                    replyBody: "Reply lorem ipsum",
                    author: {
                        user_id: 1,
                        handleName: "JaneDoe"
                    }
                }
            ]
        },
        {
            commentBody: "Another lorem ipsum 2",
            author: {
                user_id: 3,
                handleName: "MarkZucc"
            }
            replies: [
                {
                    replyBody: "Reply lorem ipsum",
                    author: {
                        user_id: 4,
                        handleName: "JohnDoe"
                    }
                }
            ]
        }
    ]
}
不知怎的,这个查询返回了我朋友的帖子,但是评论字段是空的。 我还需要过滤内部数组
回复
。我需要过滤掉我阻止的用户的回复

query = [
    {"$match": {"author.userId": {"$in": friend_ids}}},
    {"$project": {
        "postBody": 1,
        "comments": {
            "$filter": {
                "input": "$comments",
                "as": "comments",
                "cond": {"$nin": ["$$comments.author.user_id", blocked_ids]}
            }
        }
    }
]