I have an index with some documents having a field named "access_type" . It can have 2 values, either "faculty" or "students". For the documents with "faculty" as the value for "access_type", there will be another field called "faculties" which is a list of faculty name. So an example document would look like below:
{
"access_type": "faculty",
"faculties": [
"facultyId1",
"facultyId2",
"facultyId3"
]
}
Now if we have two inputs say one is for the access_type and another is for the faculties. If I get the following input "faculty" and "facultyId4" . First I need to filter out all the documents matching the access type "faculty" and then in the resulting results the "facuultyId4" should search against the field "faculties". Since the "facultyId4" is not in the above document,it should not be considered a hit. How can I implement this as an elasticsearch query?