I have a below scenario: I am creating index called company where I am creating multilevel relationship
company
|
|---------------|
department supplier
|
employee
I have created below mapping:
PUT /company
{
"mappings": {
"_doc":{
"properties":{
"join_field":{
"type":"join",
"relations":{
"company": ["supplier", "department"],
"department": "employee"
}
}
}
}
}
}
I am able to query all the departments under company using the parent id (company id)
GET /company/_doc/_search
{
"query":{
"parent_id":{
"type":"department",
"id":1
}
}
}
I am able to query all the employees under the department of the company
GET /company/_doc/_search?routing=1
{
"query":{
"has_parent":{
"parent_type":"department",
"query":{
"term":{
"name.keyword":"Development"
}
}
}
}
}
finally, my question is, how to query all the department and employees of a company in a single query instead of fetching all departments and use those departments to fetch the employees? NOTE: I am using elastic search 7+
version