I have two document types, in a parent-child relationship:
\"myParent\" : {
\"properties\" : {
\"weight\" : {
\"type\" : \"double\"
}
}
}
This I would say is a bug: it is using the myChild
mapping as the default context, even though you are inside a has_parent
query. But I'm not sure how easy the bug would be to fix. properly.
However, you can work around it by including the type
name in the full field name:
curl -XGET "http://localhost:9200/t/myChild/_search" -d'
{
"query": {
"has_parent": {
"query": {
"function_score": {
"script_score": {
"script": "_score * doc[\"myParent.weight\"].value"
}
}
},
"parent_type": "myParent",
"score_type": "score"
}
}
}'
I've opened an issue to see if we can get this fixed #4914