Boosting query

More info about Boosting query is in the official elasticsearch docs

Lets take an example to write a query with Elasticsearch DSL.

{
    "boosting" : {
        "positive" : {
            "term" : {
                "field1" : "value1"
            }
        },
        "negative" : {
            "term" : {
                "field2" : "value2"
            }
        },
        "negative_boost" : 0.2
    }
}

And now the query via DSL:

$termQuery1 = new TermQuery("field1", "value1");
$termQuery2 = new TermQuery("field2", "value2");

$boostingQuery = new BoostingQuery($termQuery1, $termQuery2, 0.2);

$search = new Search();
$search->addQuery($boostingQuery);

$queryArray = $search->toArray();