SyliusElasticsearchPlugin
SyliusElasticsearchPlugin copied to clipboard
Attribute/Option value with special characters doesn't work
Hello,
When you try to filter by an attribute value which is : 1/2" or 1" It's will result to an empty products list. But there's some products with this value.
So there's a bug on filtering value with some special characters.
Due to : https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html#_reserved_characters
Hi, I encountered the same problem, any insight on how to solve it ?
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;
}
Looks like outdated issue
