Has Child Query Usage

edit

Fluent DSL example

edit
q
.HasChild<CommitActivity>(c => c
    .Name("named_query")
    .Boost(1.1)
    .InnerHits(i => i.Explain())
    .MaxChildren(5)
    .MinChildren(1)
    .ScoreMode(ChildScoreMode.Average)
    .Query(qq => qq.MatchAll())
)

Object Initializer syntax example

edit
new HasChildQuery
{
    Name = "named_query",
    Boost = 1.1,
    Type = Infer.Relation<CommitActivity>(),
    InnerHits = new InnerHits { Explain = true },
    MaxChildren = 5,
    MinChildren = 1,
    Query = new MatchAllQuery(),
    ScoreMode = ChildScoreMode.Average
}

Example json output.

{
  "has_child": {
    "_name": "named_query",
    "boost": 1.1,
    "type": "commits",
    "score_mode": "avg",
    "min_children": 1,
    "max_children": 5,
    "query": {
      "match_all": {}
    },
    "inner_hits": {
      "explain": true
    }
  }
}