setTieBreaker() public method

If not set, defaults to 0.0.
public setTieBreaker ( float $tieBreaker )
$tieBreaker float
Esempio n. 1
0
 /**
  * Find all documents where the value is matched in the fields. The type option
  * allows you to specify the type of match, can be best_fields, most_fields,
  * cross_fields, phrase, phrase_prefix.
  *
  * best_fields finds documents which match any field, but uses the _score
  * from the best field.
  *
  * most_fields finds documents which match any field and combines the _score
  * from each field.
  *
  * cross_fields treats fields with the same analyzer as though they were
  * one big field. Looks for each word in any field.
  *
  * phrase runs a match_phrase query on each field and combines the _score
  * from each field.
  *
  * phrase_prefix runs a match_phrase_prefix query on each field and combines
  * the _score from each field.
  *
  * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-multi-match-query.html
  *
  * @param array $fields The fields to search in
  * @param string $query The string to search for
  * @param string $type The match type
  * @param bool $fuzzy Set whether the match should be fuzzy
  * @param float $tieBreaker Can be between 0.0 and 1.0
  * @param string $operator Can be 'and' or 'or'
  * @return Query
  */
 public function multiMatch(array $fields, $query, $type = 'phrase', $fuzzy = false, $tieBreaker = 0.0, $operator = 'and')
 {
     $match = new MultiMatch();
     $match->setFields($fields);
     $match->setQuery($query);
     $match->setType($type);
     if ($fuzzy) {
         $match->setFuzziness('AUTO');
     }
     if ($type == 'best_fields') {
         $match->setTieBreaker($tieBreaker);
     }
     if ($type == 'cross_fields') {
         $match->setOperator($operator);
     }
     $query = $this->newQuery($match);
     $this->query[] = $query;
     return $query;
 }