Conversation
These languages were missing from the analyzer map, so their indices fell back to the English analyzer. CJK text has no word separators, so standard tokenization produces unusable tokens and search results. Map zh-hans, zh-hant, ja and ko to the built-in cjk analyzer. The _cjk_ predefined stopword list is applied through the existing stopwords wiring; no snowball or stemmer exists for these languages, which follows the same path as Arabic and Thai.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
References #56 (choosing the correct language analyzer).
Problem
The analyzer map in
TranslateLanguageshas no entry for Chinese, Japanese or Korean, sogenerateAnalysisLanguages()falls back to theenglishanalyzer forzh-hans,zh-hant,jaandkoindices. CJK text has no word separators, so standard tokenization turns whole sentences into single tokens and search on those languages is effectively broken.Fix
One line: map those four WPML language codes to Elasticsearch's built-in
cjkanalyzer, which tokenizes CJK text into overlapping bigrams.Everything downstream works through the existing wiring, unchanged:
generateIndexByIndexable()builds the stopword list as'_' . analyzer . '_'→_cjk_, which is one of Elasticsearch's predefinedstopword lists.
cjkis not in$snowballLanguages, so the snowball filter keeps its default — the same path Arabic and Thai already take.cjkis not in$stemmerLanguages, so no stemmer filter is added — no stemmer exists for these languages (again like Arabic/Thai; see also the Thai stemmer fix in 2.0.5).Verification
cjkanalyzer and_cjk_stopword list verified against the Elasticsearch built-in language analyzer / stop filter references.