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

  1. elliotcondon
    Posted 2 years 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'



  2. elliotcondon
    Posted 2 years 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?


  3. Mikko Saari
    Plugin Author

    Posted 2 years 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 =)

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Relevanssi - A Better Search
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic