$bool =
new BoolQuery();
$term =
(string) $criteria->
getTerm();
$queries =
[ new MatchQuery('fullTextBoosted',
$term,
['boost' => 10
]), // boosted word matches
new MatchQuery('fullText',
$term,
['boost' => 5
]), // whole word matches
new MatchQuery('fullText',
$term,
['fuzziness' => 'auto', 'boost' => 3
]), // word matches not exactly =>
new MatchPhrasePrefixQuery('fullText',
$term,
['boost' => 1, 'slop' => 5
]), // one of the words begins with: "Spachtel" => "Spachtelmasse"
new WildcardQuery('fullText', '*' .
mb_strtolower($term) . '*'
), // part of a word matches: "masse" => "Spachtelmasse"
new MatchQuery('fullText.ngram',
$term),
];
foreach ($queries as $query) { $bool->
add($query, BoolQuery::SHOULD
);
} $bool->
addParameter('minimum_should_match', 1
);
return $bool;
}