SyliusElasticsearchPlugin
SyliusElasticsearchPlugin copied to clipboard
Filtering not working with some characters
Filtering don`t work for products, which have one of those characters / % " ' in option or attribute value.
Same with characters -, ( and ). Very annoying when you are in tech market, and you have laptop with 'GTX 1080 (4GB)' and screen size '15.5"' (" is symbol for inches), or earphones with frequency range '40Hz - 38 kHz'. Workaround could be turning those characters to HTML character codes like " but that also doesn't seam to work.
Can this issue be officially addressed?
We switched to the Match query recently with fuzziness options. Should work now.
We switched to the Match query recently with fuzziness options. Should work now.
I'm still having this issue. All my options / attributes have that kind of characters.
We have found a bad workaround... But it's working... at least for attributes. Decorate HasAttributesQueryBuilder and then :
public function buildQuery(array $data): ?AbstractQuery
{
$attributeQuery = new BoolQuery();
foreach ((array) $data['attribute_values'] as $attributeValue) {
// Add match because it can handle keyword analyzer and then analyze special char like (/...
$termQuery = new Match();
// add keyword to find exact match with special char too
$termQuery->setParam($data['attribute'].'.keyword', $attributeValue);
$attributeQuery->addShould($termQuery);
// 'Term' because it can handle boolean value too and not Match
$termQuery = new Term();
$termQuery->setTerm($data['attribute'], $attributeValue);
$attributeQuery->addShould($termQuery);
}
return $attributeQuery;
}
I think the problem has been solved in the meantime, I tested and can't reproduce.