Page 1 of 1

Tweaking the search term - apostrophe issues - vQmod

Posted: Fri Aug 09, 2013 4:23 pm
by tonybarnes
Various products in our shop end with 's - this was throwing up issues with the search engine as people wouldn't necessarily put the apostrophe into the search query themselves.

Search term:-
udos choice

Results:-
0

Search term:-
udo's choice

Results:-
9

Quite a bad result for the apostrophe free search term!!!

Anyways, bit of a dig later, I've tweaked the search engine to simply ignore the last letter of any word entered - now all 9 results come up when the apostrophe is not used.

vQmod for 1.5.5 attached

Re: Tweaking the search term - apostrophe issues - vQmod

Posted: Fri Aug 09, 2013 10:34 pm
by butte
Most engines are blind to punctuation and plurals. Escaping comment marks (both apostropy and quotation, ' and ") can be necessary at code level, as you're well aware, some might not understand that. Thank you. Notice specificity of version before using it, if prior, test.

Re: Tweaking the search term - apostrophe issues - vQmod

Posted: Sat Aug 10, 2013 12:04 am
by tonybarnes
I've just had a quick search through some old versions I have - looks like this will only slot into 1.5.5 or above - product.php had a big old re-write by the look of it!!

Re: Tweaking the search term - apostrophe issues - vQmod

Posted: Sat Aug 10, 2013 12:46 am
by rph
You can also use a regular expression so you're only targeting words ending with the letter "s".

Code: Select all

LIKE '%" . $this->db->escape(preg_replace('/([\']?[s])$/', '', $word))

Re: Tweaking the search term - apostrophe issues - vQmod

Posted: Sat Aug 10, 2013 12:48 am
by butte
[We posted almost simultaneously, so as to "only slot into":] In particular, some very short but sly little changes in search syntax have been made along the way. Lookin' at 'em we might not even notice or see them as cognates, but to the machine they're as different as Greek and Welsh.

Re: Tweaking the search term - apostrophe issues - vQmod

Posted: Tue Aug 13, 2013 9:36 pm
by tonybarnes
Nice thinking rph - but as we've also got a live search on ours that queries the DB as terms are added, that would be a tiny bit more server work I think??? Not completely sure!!

Re: Tweaking the search term - apostrophe issues - vQmod

Posted: Wed Aug 14, 2013 12:45 am
by Shadowsong
I was also looking for a way to tweak the storefront product search when there are products with an apostrophe. Any suggestions for an example like :

L'oreal or Loreal

If you use the apostrophe you get the products that have it in their name...

If you don't use it it eliminates all the products that have it in their name....

Is there a way to tweak the search so that if the Product has "L'oreal" in the product name, the person can still find that product if they type "Loreal" into the search? Other than using the Product Tag option in the Product area.

-Tim

Re: Tweaking the search term - apostrophe issues - vQmod

Posted: Fri Aug 16, 2013 12:42 am
by tonybarnes
Upadted version

Just deleted this as I thought it was borked, but it was fine.. duh!

Think this will sort your issue?? Dunno, seems to work on ours, just ditches apostrophes

Re: Tweaking the search term - apostrophe issues - vQmod

Posted: Fri Aug 16, 2013 12:47 am
by rph
tonybarnes wrote:Nice thinking rph - but as we've also got a live search on ours that queries the DB as terms are added, that would be a tiny bit more server work I think??? Not completely sure!!
preg_replace is slower than substr_replace since it's much more robust but we're still talking about a process that only takes 1 ten-thousandth of a second.