-
Aivaras Gotovskis authoredAivaras Gotovskis authored
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
DisMax.md 1.05 KiB
Dis Max query
More info about Dis Max query is in the official elasticsearch docs
A query that generates the union of documents produced by its subqueries, and that scores each document with the maximum score for that document as produced by any subquery, plus a tie breaking increment for any additional matching subqueries.
Lets try to write this example
{
"dis_max" : {
"tie_breaker" : 0.7,
"boost" : 1.2,
"queries" : [
{
"term" : { "age" : 34 }
},
{
"term" : { "age" : 35 }
}
]
}
}
In DSL :
$term1 = new TermQuery('age', 34);
$term2 = new TermQuery('age', 35);
$disMax = new DisMaxQuery();
$disMax->addParameter('tie_breaker', 0.7);
$disMax->addParameter('boost', 1.2);
$disMax->addQuery($term1);
$disMax->addQuery($term2);
$search = new Search();
$search->addQuery($disMax);
$queryArray = $search->toArray();