Support » Plugin: Relevanssi - A Better Search » Search won’t return words with special characters

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


    Because you use the German collation, you need to add this filter function to keep the umlauts intact:

    Add that function and rebuild the index.

    Thread Starter 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 6 months ago by morvy.
    Plugin Author Mikko Saari


    “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


    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


    Thank you for giving such quick feedback.

Viewing 7 replies - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.