Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Mikko Saari

    (@msaari)

    Because you use the German collation, you need to add this filter function to keep the umlauts intact: https://www.relevanssi.com/user-manual/filter-hooks/relevanssi_remove_punctuation/#remove_accents

    Add that function and rebuild the index.

    Thread Starter morvy

    (@morvy)

    If I keep accents, search will find a word with accents but not without them. I believe I’m missing something, but I’m trying filters one after another that I find on gist and in the docs and I can’t get both versions working.

    I also tried different collations, (german, unicode, both as utf8 and utf8mb4)

    • This reply was modified 2 years, 6 months ago by morvy.
    Plugin Author Mikko Saari

    (@msaari)

    “If I keep accents, search will find a word with accents but not without them.”

    This is correct, and how the search should work in that case.

    If that is not what you want, you need to run remove_accents(). There’s one wrinkle here, though: in German locales, remove_accents() doesn’t remove the umlauts. Instead, ? becomes ae, ü becomes ue and so on. So “natürlich” would be indexed as “natuerlich” and thus can only be found when searching for “natürlich” or “natuerlich”, but not when you search for “naturlich”.

    If you want the search to ignore accents and umlauts, use the utf8mb4_unicode_ci collation, let the remove_accents() run and add this:

    add_filter( 'relevanssi_remove_punctuation', function( $string ) {
      $chars = array(
        'ü' => 'u',
        '?' => 'a',
        '?' => 'o',
        'ü' => 'U',
        '?' => 'A',
        '?' => 'O',
      );
      return strtr( $string, $chars );
    }, 8 );

    This would make Relevanssi index the umlauted characters without the umlauts and without the extra “e” remove_accents() adds.

    Thread Starter morvy

    (@morvy)

    Thanks a lot, this does the job!

    I have the same problem. I don’t know where to write your codes. I’m inexperienced at this. I appreciate your help.

    Plugin Author Mikko Saari

    (@msaari)

    Thank you for giving such quick feedback.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Search won’t return words with special characters’ is closed to new replies.