$queries[] =
new WildcardQuery($searchField, '*' .
$token . '*'
);
if ($item['tokenize'
]) { $queries[] =
new MatchQuery($searchField,
$token,
['fuzziness' => 'auto', 'boost' => 3 *
$ranking]);
$queries[] =
new MatchQuery($ngramField,
$token);
} if (str_contains($item['field'
], '.'
) && !
str_contains($item['field'
], 'customFields'
)) { $nested =
strtok($item['field'
], '.'
);
foreach ($queries as $query) { $tokenBool->
add(new NestedQuery($nested,
$query), BoolQuery::SHOULD
);
} continue;
} foreach ($queries as $query) { $tokenBool->
add($query, BoolQuery::SHOULD
);
} } $bool->
add($tokenBool,
$isAndSearch ? BoolQuery::MUST : BoolQuery::SHOULD
);
}