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

  1. danteand
    Posted 3 years 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:


    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.


  2. Mikko Saari
    Plugin Author

    Posted 3 years 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);


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

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

  3. danteand
    Posted 3 years 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
    Plugin Author

    Posted 3 years ago #

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

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