I have a parent child relationship in my elasticsearch 7.9 where I am having the car as a parent type and it has multiple child types like honda, suzuki, volvo now I want to have a child of type volvo and parent type is car.
{
"query": {
"has_parent": {
"parent_type": "car",
"query": {
"has_child": {
"type": "volvo",
"query": {
"match_all": {}
}
}
}
}
}
}
It is returning the objects having child type honda as well. Where I am wrong ? Thanks.
- what should be the query where I want the parent_type car with an id xxxxx and child is volvo.
Updated
Here is the mapping.
{
"car": {
"mappings": {
"properties": {
"_class": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"made": {
"type": "nested",
"properties": {
"model": {
"type": "keyword"
}
}
},
"relation": {
"type": "join",
"eager_global_ordinals": true,
"relations": {
"car": ["volvo", "suzuki", "honda"]
}
}
}
}
}
}