Jump to content

  • You cannot start a new topic
  • You cannot reply to this topic

Modify Search results Rate Topic   - - - - -

 
  • hbtrading
  • Senior Member
  • Members
  • Join Date: 07-Oct 09
  • 204 posts

Posted 10 December 2010 - 04:58 PM #1

When doing a search for rings on my website it returns earrings which i do not want obviously, so my questions is how would I modify the search results so it doesn't return results containing part of the search term when in occurs in middle of a word (as opposed to the beginning of a word which I do want the search results to show)

 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 11764 posts

Posted 12 December 2010 - 11:12 PM #2

the whole search area needs to be more tailorable. An admin needs to be able to specify what options to make available to their customers and the customers need to be able to choose more simply. I.e. for any search phrase there needs to be a selector for "contains", 'exact match', 'all words'or 'one or more words'.

No cart can meet the needs of all merchants without making this stuff configurable.

I could probably dig out the area of code where you'd change a condition from 'LIKE' to '=' but that would be a mod to the core.

EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.


 
  • 2020
  • Senior Member
  • Members
  • Join Date: 11-Feb 07
  • 509 posts

Posted 13 December 2010 - 12:30 AM #3

I don't have a working solution yet, but it looks like the change needs to be made to fn.catalog.php around line #3030.

			if ($params['pfull'] == 'Y') {
$tmp .= db_quote(" OR descr1.full_description LIKE ?l", "%$piece%");
}


The LIKE in those queries could be replaced with a REGEXP like this:
WHERE full_description REGEXP '[[:<:]]$string[[:>:]]' = 1

That REGEXP does a nice job of only returning whole-word matches when I test it in phpmyadmin. Unfortunately, I don't know PHP well enough to integrate it correctly. Can you lend a hand, Tony?

A better solution might be to add a "stop-word list" field to the product. Words in this field would explicitly prevent the item from appearing in search results upon a keyword match.

While investigating this, I noticed that the Search Words are always used by the search function - even when the "keywords" checkbox is unchecked. Bug report submitted.

Glen

 
  • hbtrading
  • Senior Member
  • Members
  • Join Date: 07-Oct 09
  • 204 posts

Posted 13 December 2010 - 01:47 AM #4

thanks guys, I'll try playing around with this to see if I get anywhere.

 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 11764 posts

Posted 13 December 2010 - 07:37 AM #5

Assuming your REGEX is what you want, then the code should be changed to:
if ($params['pfull'] == 'Y') {
                $tmp .= db_quote(" OR descr1.full_description REGEX ?s = 1", "[[:<:]]$piece[[:>:]]");
            }  

I'm not familiar enough with using REGEX in mySQL statements. I'm assuming it returns the number of matches, hence the " = 1".

EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.


 
  • Offline
  • Member
  • Members
  • Join Date: 13-Oct 09
  • 85 posts

Posted 03 April 2012 - 06:57 PM #6

Did you all ever figure out how to have the search match who words only?

Thanks,

Chris
Chris Edwards