• Resolved jpegtobbe

    (@jpegtobbe)


    I have a WooCommerce-site.
    I have products named like “cc 150”. If the user searches “cc150” there will be no match. Do Relevanssi have the posibility to match on “cc150” when the product name is “cc 150”?

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

    (@msaari)

    You can make Relevanssi index the product names without spaces, if you want to.

    add_filter('relevanssi_content_to_index', 'rlv_spaceless_name', 10, 2);
    function rlv_spaceless_name($content, $post) {
        $nameless_title = str_replace(" ", "", $post->post_title);
        $content .= " " . $nameless_title;
        return $content;
    }

    Add this to your theme functions.php and rebuild the index. Now Relevanssi will index the post name without spaces, and “cc 150” will be found both as “cc 150” or “cc150”.

    Thread Starter jpegtobbe

    (@jpegtobbe)

    Ah thank you!
    But i realise now that maybe i told you a little to little details ??

    I think i have to solve this with a custom field on the product where i enter all the keywords that the product should make a hit on in the search form.

    The names of the products can be like this:
    Sennheiser CC 550
    Sennheiser CC 550 IP
    Sennheiser MB Pro 2 UC ML

    So as you see i apparently didt tell you the whole story, sorry. So when the spaces are removed i get a name like: “SennheiserCC550IP” and the user maybe do a search by typing “cc 550” or “cc550” if i guess.

    This problem is why google exists today i think ??

    What do you think, should i go with the custom fields solution? (aprox 500 products in this case)

    Thanks for the help!

    Plugin Author Mikko Saari

    (@msaari)

    The simplest solution seems to be to list the most common alternative spellings in a custom field, yes.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Match on similar keyword?’ is closed to new replies.