/**
* Find all documents where the values are matched in the field. The type option
* allows you to specify the type of match, can be either phrase or phrase_prefix.
*
* The phrase match analyzes the text and creates a phrase query out of the
* analyzed text.
*
* The phrase prefix match is the same as phrase, except that it allows for
* prefix matches on the last term in the text.
*
* @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-match-query.html
*
* @param string $field The field to search in the index
* @param string $query The values to search for
* @param string $type The match type
* @param bool $fuzzy Set whether the match should be fuzzy
* @return Query
*/
public function match($field, $query, $type = 'phrase', $fuzzy = false)
{
$match = new Match();
$match->setFieldQuery($field, $query);
$match->setFieldType($field, $type);
if ($fuzzy) {
$match->setFieldFuzziness($field, 'AUTO');
}
$query = $this->newQuery($match);
$this->query[] = $query;
return $query;
}