WordPress.org

Support

Support » Plugins and Hacks » [Plugin: Relevanssi – A Better Search] [Plugin: Relevanssi] Hyphens in search terms

[Plugin: Relevanssi – A Better Search] [Plugin: Relevanssi] Hyphens in search terms

  • Graham Armfield
    Member

    @grahamarmfield

    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/

Viewing 1 replies (of 1 total)
  • Plugin Author Mikko Saari
    Participant

    @msaari

    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);
    }
Viewing 1 replies (of 1 total)
  • The topic ‘[Plugin: Relevanssi – A Better Search] [Plugin: Relevanssi] Hyphens in search terms’ is closed to new replies.