• Resolved JD

    (@jutta0303)


    Hi, I noticed today on my site using Relevanssi, that when I search for a phrase that includes an apostrophe in a word, wrapped in quotes, Relevanssi yields no search results.

    For example I know this phrase exists on my site: “the world’s thinking”

    There are two different scenarios that happen:
    1.) I type this into the search bar: “the world’s thinking” (including the double quotes and a “straight” apostrophe) — my results are shown, however the actual search phrase is not shown in the excerpt; it’s just showing the first paragraph of the page containing the search phrase.

    2.) I copy the actual phrase from the page that includes the phrase and paste it into the search bar: “the world’s thinking” (note, that this makes the apostrophe “curly” instead of straight) — my search results in this case are, “No Results Found.”

    Can you tell me what’s happening here? Why is this not working? The search function works PERFECTLY for terms and phrases that do not include an apostrophe (both, scenario 1 and 2 yield proper results for non-apostrophized terms/phrases with the search terms/phrases bolded in the search result excerpts).

    https://www.ads-software.com/plugins/relevanssi/

Viewing 15 replies - 1 through 15 (of 19 total)
  • Plugin Author Mikko Saari

    (@msaari)

    Phrase searches are super literal. If your database has a straight apostrophe, searching for a curly apostrophe doesn’t find the results and vice versa.

    If you’re not using phrases, Relevanssi just removes the whole apostrophe and doesn’t care about it at all.

    That’s a bit of a problem, yes, but with the way phrase searching is done in Relevanssi right now, there’s no easy solution to make it better, as the underlying database search is out of my control and that’s making the search so literal.

    Thread Starter JD

    (@jutta0303)

    Hi Mikko,

    Thanks for the reply. What you’re saying makes sense, but it brings up one more question for me. I hope you can speak to it:

    You’re saying, if my database has straight apostrophes, searching for a curly apostrophe doesn’t give results. That makes sense. On the other hand it would then make sense to me that the first scenario I described should yield “proper” results including the correct custom excerpt with the search phrase bolded; however, this isn’t the case. Could you tell me why I’m not seeing the custom excerpt on those searches?

    Just to clarify, the custom excerpts work for all other search queries.

    Plugin Author Mikko Saari

    (@msaari)

    The custom excerpt code doesn’t like the apostrophe, for some reason. It doesn’t work all that well with apostrophes even when phrases are not involved.

    Thread Starter JD

    (@jutta0303)

    Thanks Mikko. Any idea if a future update of the Relevanssi plugin will feature better functionality for searches including apostrophes?

    Thread Starter JD

    (@jutta0303)

    Hi Mikko,

    Is there a way for Relevanssi to not care whether I’m searching for a phrase including a single curly quote or a single straight quote? I.e., searching for “the world’s thinking” (curly) would also search for “the world’s thinking” (straight) and vice versa and give results for both?

    Just like in a Google search and other search engines, when searching for phrases with straight quotes, the search yields the proper results including straight and curly quotes. In other words, a find with straight quotes will also find curly quotes and vice versa.

    Plugin Author Mikko Saari

    (@msaari)

    Not really, at the moment, as the MySQL database search underneath cares a lot about whether the apostrophe is straight or curly. I’d have to rework the search quite a bit. Also, it’s not just apostrophes, but all sorts of other punctuation that’s also a problem. So not all that simple.

    Google is a billion dollar project, Relevanssi is something one person is doing as a hobby.

    Thread Starter JD

    (@jutta0303)

    Fair enough! Thank you so much with all your help Mikko!!!

    Thread Starter JD

    (@jutta0303)

    Hi Mikko,

    One more follow-up question:

    I did end up doing a database search & replace; I replaced all curly single and double quotes with straight ones. Now, the search works in a way where searches that include a phrase with a straight apostrophe (e.g., “the world’s thinking”) yield the proper results and the searched phrase is bolded in the search results. Which is really awesome!

    For the site I’m working on it could be particularly helpful for searches to work in the same way with curly quotes. The whole site is an online version on a book, and it’s possible the people may find a quote of this book somewhere online, then copy that quote and paste it into the search bar on my site; in this case it’s possible that the phrase they copy could contain a curly quote. Is there any way for Relevanssi to disregard the curly quote in a phrase search? I tried adding a curly quote into the stopwords, but that didn’t help.

    Or do you know of a way where, when a phrase including a curly quote is searched for, Relevanssi “translates” into a straight quote? In other words, it would transform the curly quote into a straight one?

    Thank you!

    Plugin Author Mikko Saari

    (@msaari)

    I took a look at the MySQL documentation and there may be a fairly easy solution, actually.

    Try this: replace the lib/common.php in your Relevanssi folder with this file. https://dl.dropboxusercontent.com/u/9585896/common.php

    That might make the phrase search work with all sorts of quotes and apostrophes.

    Thread Starter JD

    (@jutta0303)

    This is pretty cool! Thank you. Do you think this is something you may implement in the future? Or do you see any way that having the search function work in this way could somehow negatively affect the functionality of Relevanssi?

    The one thing I notice with this setup is that the custom excerpts aren’t getting generated, but you mentioned before that they don’t work so well when apostrophes are involved. If there’s any way to get those to work, I would be totally extatic! ??

    Thank you so much, Mikko. Your support is fantastic!

    Thread Starter JD

    (@jutta0303)

    Oh, and if you do not think you’ll implement this into a future update, is there any way for me to implement this common.php into my child theme?

    Plugin Author Mikko Saari

    (@msaari)

    If it works then yes, it’ll be included in the next version. I don’t really have good data to test this on, so I need some help.

    Thread Starter JD

    (@jutta0303)

    I see, well I think you can feel free to use my site:
    https://acourseinmiraclesnow.com

    Seems to be working very well for me!

    Thread Starter JD

    (@jutta0303)

    Let me know if there’s anything I/my team can do to help.

    adamsc1

    (@adamsc1)

    As a simple work around could one add ’ = ‘ to the synonym list and turn on fuzzymatch?

Viewing 15 replies - 1 through 15 (of 19 total)
  • The topic ‘Searches including apostrophes yield no results’ is closed to new replies.