Skip to main contentSkip to footer

Korean has postpositions, which complicate things for Relevanssi. Fortunately, it’s easy to clean up the most common postpositions from the words. Add this function to your site:

add_filter( 'relevanssi_stemmer', 'relevanssi_korean_plural_stemmer' );
function relevanssi_korean_plural_stemmer( $term ) {
    $len  = strlen( $term );
    $end1 = substr( $term, -1, 1 );
    if ( '은' === $end1 && $len > 2 ) {
        $term = substr( $term, 0, -1 );
    }
    elseif ( '에' === $end1 && $len > 2 ) {
        $term = substr( $term, 0, -1 );
    }
    elseif ( '는' === $end1 && $len > 2 ) {
        $term = substr( $term, 0, -1 );
    }
    elseif ( '이' === $end1 && $len > 2 ) {
        $term = substr( $term, 0, -1 );
    }
    elseif ( '가' === $end1 && $len > 2) {
        $term = substr( $term, 0, -1 );
    }
    elseif ( '을' === $end1 && $len > 2) {
        $term = substr( $term, 0, -1 );
    }
    elseif ( '를' === $end1 && $len > 2) {
        $term = substr( $term, 0, -1 );
    }
    elseif ( '와' === $end1 && $len > 2) {
        $term = substr( $term, 0, -1 );
    }
    elseif ( '과' === $end1 && $len > 2) {
        $term = substr( $term, 0, -1 );
    }
    elseif ( '로' === $end1 && $len > 2) {
        $term = substr( $term, 0, -1 );
    }
    elseif ( '으로' === $end1 && $len > 2) {
        $term = substr( $term, 0, -1 );
    }
    elseif ( '도' === $end1 && $len > 2) {
        $term = substr( $term, 0, -1 );
    }
    elseif ( '만' === $end1 && $len > 2) {
        $term = substr( $term, 0, -1 );
    }
    elseif ( '처럼' === $end1 && $len > 2) {
        $term = substr( $term, 0, -1 );
    }
    elseif ( '의' === $end1 && $len > 2) {
        $term = substr( $term, 0, -1 );
    }
    return $term;
}

After you’ve added this function, rebuild the index. You also need to adjust the minimum word length to 2, as many Korean words are only two characters long.

Cheonmu created this function and posted it at the Relevanssi support forums.

Your account

Not logged in. Log in to see your license details.

Search

Popular Resources

Most important Relevanssi debugging trick

When you have problems with Relevanssi, these are the first steps to take: Make sure you have the latest version of Relevanssi. If not, upgrade. Try deactivating the plugin and reactivating it. Are you using Yoast Local SEO? Read this. Try deleting the plugin and reinstalling it from scratch. If…

WooCommerce 4.4 problems
Updating WooCommerce to version 4.4 breaks Relevanssi searches. After updating WooCommerce to version 4.4, Relevanssi searches no longer find results.…

Related Posts:

Comment Section:

Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.
You need to agree with the terms to proceed