Post by tonybarnes » Fri Aug 09, 2013 4:23 pm

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

New member

Posts

Joined
Thu Dec 06, 2012 1:09 am

Post by butte » Fri Aug 09, 2013 10:34 pm

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.

Guru Member

Posts

Joined
Wed Mar 20, 2013 6:58 am

Post by tonybarnes » Sat Aug 10, 2013 12:04 am

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!!

New member

Posts

Joined
Thu Dec 06, 2012 1:09 am

Post by rph » Sat Aug 10, 2013 12:46 am

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))

-Ryan


rph
Expert Member

Posts

Joined
Fri Jan 08, 2010 5:05 am
Location - Lincoln, Nebraska

Post by butte » Sat Aug 10, 2013 12:48 am

[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.

Guru Member

Posts

Joined
Wed Mar 20, 2013 6:58 am

Post by tonybarnes » Tue Aug 13, 2013 9:36 pm

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!!

New member

Posts

Joined
Thu Dec 06, 2012 1:09 am

Post by Shadowsong » Wed Aug 14, 2013 12:45 am

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

Newbie

Posts

Joined
Mon May 14, 2012 12:56 am

Post by tonybarnes » Fri Aug 16, 2013 12:42 am

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

Attachments


New member

Posts

Joined
Thu Dec 06, 2012 1:09 am

Post by rph » Fri Aug 16, 2013 12:47 am

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.

-Ryan


rph
Expert Member

Posts

Joined
Fri Jan 08, 2010 5:05 am
Location - Lincoln, Nebraska
Who is online

Users browsing this forum: No registered users and 6 guests