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;
} protected function stripText(string
$text): string
{ // Remove all html elements to save up space
$text =
strip_tags($text);
if (mb_strlen($text) >= 32766
) { return mb_substr($text, 0, 32766
);
}