WordPress.org

Ready to get started?Download WordPress

Forums

Relevanssi - A Better Search
[resolved] curly or smart apostrophe vs straight (4 posts)

  1. danteand
    Member
    Posted 1 year ago #

    I'm using Relevanssi 3.0.4 and had unexpected results when searching for a term which contained possessive words. For example, the results of a query for President's are not equivalent to the results for President’s (using straight apostrophe vs curly).

    This thread gave great instructions on how to replace the default punctuation replace function with my own to deal with the issue:

    http://wordpress.org/support/topic/plugin-relevanssi-a-better-search-i-am-a-newbie-how-do-i-setup-relevanssi-to-recognize-symbol?replies=9

    I copied the function, and before this line:

    $a = str_replace("’", '', $a);

    I added:

    $a = str_replace("’s", "'s", $a);

    Then reindexed. That way the curly apostrophes will be treated the same as straight apostrophes. Now a search for doctor's and doctor’s finds the same results as expected.

    Thank you for this great plugin and the valuable support provided even for the free version.

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

  2. Mikko Saari
    Member
    Plugin Author

    Posted 1 year ago #

    Ah, good point - I recently changed Relevanssi to replace straight apostrophes to spaces (instead of just removing them), but curly apostrophes are still removed. Yeah, I'll have to fix that.

    Probably better fix is to replace

    $a = str_replace("’", '', $a);

    with

    $a = str_replace("’", ' ', $a);

    That's what I'm going to do in the next version, anyway. Thanks for noticing this!

  3. danteand
    Member
    Posted 1 year ago #

    If you replace the right curly single quote, it probably makes sense to do the same with left curly single, and both left and right double curly quotes, since that's what happens with the straight ones. That way ’this’ and 'this', as well as "you're" and ”you’re“ will be equivalent.

    I can't think of many places it would matter, other than contractions and possessives (which are covered by the right curly single) but I suppose most people would expect them to be equivalent.

  4. Mikko Saari
    Member
    Plugin Author

    Posted 1 year ago #

    Yeah, that's the correct way to do it.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic