WordPress.org

Ready to get started?Download WordPress

Forums

Relevanssi - A Better Search
[Plugin: Relevanssi] Hyphens in search terms (2 posts)

  1. Graham Armfield
    Member
    Posted 2 years ago #

    Great plugin by the way - I use it on many sites.

    I'm confused about how Relevanssi deals with hyphens in search terms. I recently created a website concerning the European e-Inclusion Awards and I've used Relevanssi for the search on that site: http://www.e-inclusionawards.eu

    But unexpected and undesirable things happen if someone tries a search on e-inclusion. Basically it seems as though Relevanssi is treating e-inclusion as two words and so is finding all posts featuring 'inclusion' and all posts containing 'e'. Not surprisingly this finds many pages and all the e's in all the words are being nicely highlighted.

    I've checked my minumum word length and it is set to 3 so I'm surprised that the plugin would attempt a search on one letter in this way.

    Is there any way of enforcing the minimum word length in all portions of hyphenated words?

    Any help you can give me would be gratefully received.

    http://wordpress.org/extend/plugins/relevanssi/

  2. Mikko Saari
    Member
    Plugin Author

    Posted 2 years ago #

    Relevanssi does check the minimum word length for portions of hyphenated words. You're just being confused by the highlighting, which highlights all search terms, despite their length. The highlighting has nothing to do with the actual matching.

    Anyway, yes, Relevanssi replaces hyphens with spaces. If you wish to change that behaviour, it is possible through the relevanssi_remove_punctuation filter hook. The default function has the default priority of 10, so if you wish to override that, set your function to fire before that and remove the hyphens:

    add_filter('relevanssi_remove_punctuation', 'hyphensoff', 9);
    function hyphensoff($str) {
        return str_replace('-', '', $str);
    }

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic