WordPress.org

Ready to get started?Download WordPress

Forums

Relevanssi - A Better Search
[resolved] Underscore in title is not working in search (3 posts)

  1. elliotcondon
    Member
    Posted 12 months ago #

    Hey guys,

    Thanks for this great plugin. I'm currently using it on the resources page of the Advanced Custom Fields website.

    My problem is that a lot of my documentation has a title of 'the_field' or 'get_field' (contains an underscore).

    When someone searches for 'the_field', the resource article called 'the_field' is not being found. I have a feeling that the search is treating the '_' as a like wildcard.

    Is there a way to disable the LIKE wildcard nature?

    The outcome is to have the article 'the_field' appear in the results.

    P.S. All other searches work great. Eg: 'repeater', 'sort'

    Cheers
    Elliot

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

  2. elliotcondon
    Member
    Posted 12 months ago #

    Hey guys,

    After some good old debugging, I found my issue!

    Relevanssi is treating '_' as ' ' causing 'the_field' to become 'the field' and subsequently an array of terms ('the', 'field').

    My hack is to edit the lib/common.php file and comment out line 428:

    //$a = preg_replace('/:punct:+/u', ' ', $a);

    I wonder if it's possible to set all these params as an array which is sent through a filter allowing devs like me to remove them?

    Cheers
    Elliot

  3. Mikko Saari
    Member
    Plugin Author

    Posted 11 months ago #

    Do not edit lib/common.php, but instead note that the punctuation removal function is called through a filter hook, so you can easily replace it with a new, edited version, without needing to modify Relevanssi core files.

    So yeah, I've already thought about this =)

Reply

You must log in to post.

About this Plugin

About this Topic