Nested Query

I am new to the elasticsearch. Help me to resolve the issue..

I have a following mapping file. Which contain the companyId as property for the nested documents like forComment, from, forInfo, assignee and comments

mappings: {
approval: {
properties: {
forComment: {
properties: {
companyId: {
type: long
}
companyName: {
type: string
}
}
type: nested
}
submittalRefNumber: {
type: string
}
project_id: {
type: long
}

            <b>from</b>: {
                properties: {
                    <b>companyId</b>: {
                        type: long
                    }
                    companyName: {
                        type: string
                    }
                }
                type: nested
            }
           <b>forInfo</b>: {
                properties: {
                    <b>companyId</b>: {
                        type: long
                    }
                    companyName: {
                        type: string
                    }
                }
                type: nested
            }
           first_version_id: {
                type: long
            }
            <b>assignee</b>: {
                properties: {
                    <b>companyId</b>: {
                        type: long
                    }
                    companyName: {
                        type: string
                    }
                }
                type: nested
            }
           
            <b>comments</b>: {
                properties: {
                    <b>companyId</b>: {
                        type: long
                    }
                    companyName: {
                        type: string
                    }
                    commentId: {
                        type: long
                    }
                }
                type: nested
            }
        }
    }
}
aliases: [ ]

}

the issue i am facing is to find out the number of records where assignee.companyId = X. when i fire the bellow query i get all the records where companyId = X which includes record from comments, forInfo, assignee, from and forComment. How can i get the specific records from assignee only?

{

"size": 20,
"query": {
"bool": {
"must": [
{
"term": {
"project_id": 13828
}
},
{
"nested": {
"path": "assignee",
"query": {
"term": {
"assignee.companyId": "1223"
}
}
}
}
]
}
}
}