<commit_before>[[query-dsl-has-child-query]]
=== Has Child Query

The `has_child` filter accepts a query and the child type to run against, and
results in parent documents that have child docs matching the query. Here is
an example:

[source,js]
--------------------------------------------------
{
    "has_child" : {
        "type" : "blog_tag",
        "query" : {
            "term" : {
                "tag" : "something"
            }
        }
    }
}
--------------------------------------------------

[float]
==== Scoring capabilities

The `has_child` also has scoring support. The
supported score modes are `min`, `max`, `total`, `avg` or `none`. The default is
`none` and yields the same behaviour as in previous versions. If the
score mode is set to another value than `none`, the scores of all the
matching child documents are aggregated into the associated parent
documents. The score type can be specified with the `score_mode` field
inside the `has_child` query:

[source,js]
--------------------------------------------------
{
    "has_child" : {
        "type" : "blog_tag",
        "score_mode" : "sum",
        "query" : {
            "term" : {
                "tag" : "something"
            }
        }<commit_msg>Document `sum` as supported scoring type<commit_after>[[query-dsl-has-child-query]]
=== Has Child Query

The `has_child` filter accepts a query and the child type to run against, and
results in parent documents that have child docs matching the query. Here is
an example:

[source,js]
--------------------------------------------------
{
    "has_child" : {
        "type" : "blog_tag",
        "query" : {
            "term" : {
                "tag" : "something"
            }
        }
    }
}
--------------------------------------------------

[float]
==== Scoring capabilities

The `has_child` also has scoring support. The
supported score modes are `min`, `max`, `sum`, `avg` or `none`. The default is
`none` and yields the same behaviour as in previous versions. If the
score mode is set to another value than `none`, the scores of all the
matching child documents are aggregated into the associated parent
documents. The score type can be specified with the `score_mode` field
inside the `has_child` query:

[source,js]
--------------------------------------------------
{
    "has_child" : {
        "type" : "blog_tag",
        "score_mode" : "sum",
        "query" : {
            "term" : {
                "tag" : "something"
            }
        }
{'fraction_non_alphanumeric': 0.2165401518178186, 'fraction_numerical': 0.0, 'mean_word_length': 1.6752136752136753, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6881928', 'n_tokens_mistral': 664, 'n_tokens_neox': 648, 'n_words': 253}