Boosting Query Usage

edit

Fluent DSL example

edit
q
.Boosting(c => c
    .Name("named_query")
    .Boost(1.1)
    .Positive(qq => qq.MatchAll(m => m.Name("filter")))
    .Negative(qq => qq.MatchAll(m => m.Name("query")))
    .NegativeBoost(1.12)
)

Object Initializer syntax example

edit
new BoostingQuery()
{
    Name = "named_query",
    Boost = 1.1,
    PositiveQuery = new MatchAllQuery { Name ="filter" },
    NegativeQuery= new MatchAllQuery() { Name = "query" },
    NegativeBoost = 1.12
}

Example json output.

{
  "boosting": {
    "_name": "named_query",
    "boost": 1.1,
    "negative": {
      "match_all": {
        "_name": "query"
      }
    },
    "negative_boost": 1.12,
    "positive": {
      "match_all": {
        "_name": "filter"
      }
    }
  }
}