Hi,
in short, when I query for all mothers having any childern it only returns the mothers that also is a child of a mother. Even if the grandmother is created AFTER the mother, this mother will not be included in the result.
The below Sense commands describes the problem.
I am on ElasticSearch 2.3.1 by the way.
UPDATE: Noticed same behaviour on 5.3.0.
Regards / Mattias
DELETE test
PUT test
PUT test/kid/_mapping
{
"kid": {
"_parent": {
"type": "mom"
},
"_routing": {
"required": true
},
"properties": {
"Name": {
"type": "string"
}
}
}
}
PUT test/mom/_mapping
{
"mom": {
"_parent": {
"type": "grandma"
},
"_routing": {
"required": true
},
"properties": {
"Name": {
"type": "string"
}
}
}
}
PUT test/grandma/_mapping
{
"grandma": {
"properties": {
"Name": {
"type": "string"
}
}
}
}
// Create a grand mother
PUT test/grandma/1?refresh=true
{
"Name": "Sue the grand mother"
}
// Create an unreferenced grand mother
PUT test/grandma/50?refresh=true
{
"Name": "Renate unreferenced"
}
// Create a mother that is child of Sue
PUT test/mom/1?parent=1&refresh=true
{
"Name": "Emma daugther of the grand mother"
}
// Create a mother-less mother
PUT test/mom/2?parent=100&refresh=true
{
"Name": "Mary mother-less mother"
}
// Create a son of mother-less Mary
PUT test/kid/1?parent=2&refresh=true
{
"Name": "Lester child of mother-less mother"
}
// Create a son of Emma (tha has a mother)
PUT test/kid/2?parent=1&refresh=true
{
"Name": "Sven the grand child"
}
// Search for all mothers having children...returns only the mom (Emma) having a grandma
GET test/mom/_search
{
"query": {
"bool": {
"must": [
{
"has_child": {
"type": "kid",
"min_children": 0,
"query": {
"match_all": {}
},
"inner_hits": {
"size": 0
}
}
}
]
}
}
}
// Create the missing grand mother (mother of Mary)
PUT test/grandma/100?refresh=true
{
"Name": "Late grand mother"
}
// Search for all mothers having children...still returns only the mom having a grandma created before itself
GET test/mom/_search
{
"query": {
"bool": {
"must": [
{
"has_child": {
"type": "kid",
"min_children": 0,
"query": {
"match_all": {}
},
"inner_hits": {
"size": 0
}
}
}
]
}
}
}