WordPress.org

Ready to get started?Download WordPress

Forums

Search whole words only with international characters (4 posts)

  1. Sly_Boots
    Member
    Posted 1 year ago #

    Hey,

    so the problem is following (talking about search query now):

    • I need to search for exact words only, not strings of characters inside a word
    • I'm running a slovak website, so if the client searches for "oci", the results must show "oči" and "očí" as well

    I tried query parameters such as "s=xxx&sentence=1", which still searches inside a word and "s=xxx&exact=1" which searches for exact words, but doesn't support the second condition mentioned above.

    I didn't find any solution until now, I'd really appreciate some help. Thank you :)

  2. Chris
    Member
    Posted 1 year ago #

    As far as I know, this kind of character mapping hasn't been implemented yet, neither in PHP nor in mySQL. But maybe you can build on this approach: https://github.com/tom--/Collation-to-Charset-Table

  3. Sly_Boots
    Member
    Posted 1 year ago #

    The wordpress search with default settings has this functionality - the problem is when using the "exact" search parameter... I'm trying to find a way around this... so basically I need the default wordpress search that doesn't search for strings of characters inside words and it returns whole word matches only

  4. bcworkz
    Member
    Posted 1 year ago #

    You've tried the only two query vars that work with search. Your only recourse is to either hook the 'posts_search' filter and re-search the results for actual word matches using regexp, or completely replace the search function with your own.

    For reference, the search query is done in wp-includes/query.php around line 2197.

Topic Closed

This topic has been closed to new replies.

About this Topic