Template Query Usage

edit

Fluent DSL example

edit
q
.Template(sn => sn
    .Name("named_query")
    .Boost(1.1)
    .Inline(_templateString)
    .Params(p=>p.Add("query_string", "all about search"))
)

Object Initializer syntax example

edit
new TemplateQuery
{
    Name = "named_query",
    Boost = 1.1,
    Inline = _templateString,
    Params = new Dictionary<string, object>
    {
        { "query_string", "all about search" }
    }
}

Example json output.

{
  "template": {
    "_name": "named_query",
    "boost": 1.1,
    "inline": "{ \"match\": { \"text\": \"{{query_string}}\" } }",
    "params": {
      "query_string": "all about search"
    }
  }
}