Problem/Motivation
The 8.x change "Search removes diacritics in indexing rather than relying on database collation" described in https://www.drupal.org/node/2447357 introduces a new removeDiacritics function, \Drupal::service('transliteration')->removeDiacritics($text), which is used on search text and removes all diacritical marks from it.
Search then does "greedy matching" and returns results for both versions of the query: the one with diacritical marks and the one without. This can yield confusing, unrelated results for a multitude of languages, and is not commonly expected (= what Google does). Disregarding diacritics can change words into other words - changing Ä into A in Finnish is no more appropriate than changing it into an Y or U, because Ä is its own grapheme (it's even in the alphabet), not an extension or variant of A. For Finnish, this can result in searches for stars returning results related to stars... and catchy marching tunes. More examples below:
Finnish: tähti 'star' -> tahti 'beat', säde 'ray' -> sade 'rain', lähti 'left' -> lahti 'bay', sääri 'shin' -> saari 'island', Väinö (a man's name) -> vaino 'persecution'
Swedish: vår 'spring', 'our' -> var 'each', skön 'pretty' -> skon 'shoe'
Estonian: õlu 'beer' -> olu 'existence'
Danish: tåge 'fog' -> tage 'to take'
German: schön 'pretty' -> schon 'already', 'before'
Italian: purè 'potato mash' -> pure 'also'
French: où 'where' -> ou 'or', mûr 'ripe' -> mur 'wall', boîte 'box' -> boite 'to limp', jeûne '(a) fast' -> jeune 'young'
Proposed resolution
There are several possible choices:
- Don't remove diacritical marks at all.
- Don't do fuzzy matching, only match the input string and nothing else.
- Make removing diacritics optional per language (and probably per diacritical mark for best results), with sensible defaults.
| Comment | File | Size | Author |
|---|---|---|---|
| drupal-search-diacritics.PNG | 38.74 KB | ataimist |
Comments
Comment #2
ataimist commentedComment #15
smustgrave commentedThank you for reporting this problem. We rely on issue reports like this one to resolve bugs and improve Drupal core.
Since there has been no activity here for over 8 years we are asking if this problem persists on a currently supported version of Drupal. To help, add a comment explaining if the problem still occurs or not. Any extra detail you can provide can help others who experienced this.
Since we need more information to move forward with this issue, the status is now Postponed (maintainer needs more info). If we don't receive additional information to help with the issue, it may be closed after three months.
Thanks!
Comment #17
quietone commentedAnother 6 months and no indication if this is still valid. Therefor, I am closing this issue.
If this is incorrect, re-open the issue. Or you can create a new issue and reference this one.