You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If a multi-word synonym or expansion rule contains non ASCII US characters, indexing the thesaurus fails with the error
{"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"failed to build synonyms"}],"type":"illegal_argument_exception","reason":"failed to build synonyms","caused_by":{"type":"parse_exception","reason":"Invalid synonym rule at line 12","caused_by":{"type":"illegal_argument_exception","reason":"term: [multi word synonym] analyzed to a token (multi_word) with position increment != 1 (got: 0)"}}},"status":400}
Exemple:
{"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"failed to build synonyms"}],"type":"illegal_argument_exception","reason":"failed to build synonyms","caused_by":{"type":"parse_exception","reason":"Invalid synonym rule at line 12","caused_by":{"type":"illegal_argument_exception","reason":"term: pâte à modeler analyzed to a token (pâte_à) with position increment != 1 (got: 0)"}}},"status":400}
Reindex manually the Thesaurus (CLI) or reindex all
Expected result
The Thesaurus index should be rebuilt
Actual result
Thesaurus reindexing fails with the error mentionned above
How to fix
In \Smile\ElasticsuiteThesaurus\Model\Indexer\IndexHandler::prepareSynonymFilterData, which alters multi-word synonyms by replacing spaces by a _, add the u flag in order to support all UTF-8 characters and not only ASCII US :
/**
* Prepare the thesaurus data to be saved.
* Spaces are replaced with "_" into multiwords expression (ex foo bar => foo_bar).
*
* @param string[] $rows Original thesaurus text rows.
*
* @return string[]
*/
private function prepareSynonymFilterData($rows)
{
$rowMaper = function ($row) {
return preg_replace('/([\w])[\s-](?=[\w])/u', '\1_', $row);
};
return array_map($rowMaper, $rows);
}
The text was updated successfully, but these errors were encountered:
If a multi-word synonym or expansion rule contains non ASCII US characters, indexing the thesaurus fails with the error
Exemple:
Possible linked issue : elastic/elasticsearch#27481
Possible way to avoid the error (but with the loss of the invalid synonym rule) : elastic/elasticsearch@88c270d
Preconditions
Magento Version : 2.2.9, EE 2.3.x
ElasticSuite Version : 2.6.9, 2.8.x-dev
Environment : ElasticSearch 6.6 (and 6.8.2)
Third party modules : N/A
Steps to reproduce
Expected result
Actual result
How to fix
In
\Smile\ElasticsuiteThesaurus\Model\Indexer\IndexHandler::prepareSynonymFilterData
, which alters multi-word synonyms by replacing spaces by a_
, add theu
flag in order to support all UTF-8 characters and not only ASCII US :The text was updated successfully, but these errors were encountered: