SyliusElasticsearchPlugin icon indicating copy to clipboard operation
SyliusElasticsearchPlugin copied to clipboard

Filtering not working with some characters

Open aveblackmetalstudio opened this issue 6 years ago • 4 comments

Filtering don`t work for products, which have one of those characters / % " ' in option or attribute value.

aveblackmetalstudio avatar Dec 20 '18 13:12 aveblackmetalstudio

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?

filipcro avatar Feb 26 '19 10:02 filipcro

We switched to the Match query recently with fuzziness options. Should work now.

bitbager avatar May 21 '19 19:05 bitbager

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.

ghost avatar Dec 02 '19 14:12 ghost

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;
}

smashou avatar Jul 10 '20 15:07 smashou

I think the problem has been solved in the meantime, I tested and can't reproduce.

rafalmal avatar Mar 31 '23 11:03 rafalmal