Page 3 of 4 FirstFirst 1234 LastLast
Results 21 to 30 of 31
  1. #21
    Join Date
    Aug 2007
    Location
    Gijón, Asturias, Spain
    Posts
    2,571
    Plugin Contributions
    30

    Default Re: Improving search results

    Since the thread title is Improving Search Results perhaps this warrants a mention:

    https://github.com/lat9/prioritize_matching_names
    Steve
    github.com/torvista: Spanish Language Pack, Google reCaptcha, Structured Data, Multiple Copy-Move-Delete, Image Checker, BackupMySQL Admin/Auto...

  2. #22
    Join Date
    Jul 2009
    Posts
    14
    Plugin Contributions
    1

    Default Re: Improving search results

    Quote Originally Posted by torvista View Post
    Since the thread title is Improving Search Results perhaps this warrants a mention:

    https://github.com/lat9/prioritize_matching_names
    That's a good update since it makes products with the search keywords in the product name appear before ones just matching words in the description. A slight enhancement would be to have product names that begin with the keywords listed first. I haven't tested it, but something like the following might work:

    Code:
    public function update(&$class, $eventID) 
        {
            switch ($eventID) {
                case 'NOTIFY_SEARCH_SELECT_STRING':
                    global $db, $keywords, $select_str;
                    if (!empty($keywords) && zen_parse_search_string(stripslashes($_GET['keyword']), $search_keywords)) {
                        $in_name_select1 = '';
                        $in_name_select2 = '';
                        foreach ($search_keywords as $current_keyword) {
                            switch ($current_keyword) {
                                case '(':
                                case ')':
                                case 'and':
                                case 'or':
                                    $in_name_select1 .= " $current_keyword ";
                                    $in_name_select2 .= " $current_keyword ";
                                    break;
    
                                default:
                                    $in_name_select1 .= "pd.products_name LIKE '%:keywords'";
                                    $in_name_select1 = $db->bindVars($in_name_select1, ':keywords', $current_keyword, 'noquotestring');
                                    $in_name_select2 .= "pd.products_name LIKE '%:keywords%'";
                                    $in_name_select2 = $db->bindVars($in_name_select2, ':keywords', $current_keyword, 'noquotestring');
                                    break;
                            }
                        }
                        $select_str .= ", IF ($in_name_select1, 1, 0) AS in_name1, IF ($in_name_select2, 1, 0) AS in_name2 ";
                        $this->order_by = ' in_name1 DESC, in_name2 DESC,';
                    }        
                    break;
    
                case 'NOTIFY_SEARCH_ORDERBY_STRING':
                    global $listing_sql;
                    $listing_sql = str_ireplace('order by', 'order by' . $this->order_by, $listing_sql);
                    break;
    
                default:
                    break;
            }

  3. #23
    Join Date
    Apr 2019
    Posts
    242
    Plugin Contributions
    0

    Default Re: Improving search results

    Hi @jadebox, I just tried your modified code in zc1.58. Unfortunately, it doesn't make any difference on my search result (not work). Actually the original code from github doesn't make any difference neither. Not sure why...I have changed "header_php.php" file back to the default before the test. No log file is received during my test. The original code is based on zc 1.53 though.

    For your mentioned code, I suspected you want to rank by the product name at first, then product description, correct? So your following line below

    $in_name_select2 .= "pd.products_name LIKE '%:keywords%'";

    It should be changed to the following, if I'm correct.

    $in_name_select2 .= "pd.products_description LIKE '%:keywords%'";

    It doesn't work no matter I changed the line above or not...
    Last edited by njcyx; 9 Nov 2022 at 07:01 PM.

  4. #24
    Join Date
    Jul 2009
    Posts
    14
    Plugin Contributions
    1

    Default Re: Improving search results

    Quote Originally Posted by njcyx View Post
    Hi @jadebox, I just tried your modified code in zc1.58. Unfortunately, it doesn't make any difference on my search result (not work). Actually the original code from github doesn't make any difference neither. Not sure why...I have changed "header_php.php" file back to the default before the test. No log file is received during my test. The original code is based on zc 1.53 though.

    For your mentioned code, I suspected you want to rank by the product name at first, then product description, correct? So your following line below

    $in_name_select2 .= "pd.products_name LIKE '%:keywords%'";

    It should be changed to the following, if I'm correct.

    $in_name_select2 .= "pd.products_description LIKE '%:keywords%'";

    It doesn't work no matter I changed the line above or not...
    No, I wanted it to sort products that have names that start with the keywords before products that just have the keyword in the name. The first "like" returns True for product names starting with the keywords (:keyword%). The second returns True for product names which include the keywords anywhere (%: keywords%). Using "DESC" causes tbe LIKEs that return True to be listed before the ones that are False.

    So, if your keyword is "Red" then a product called "Red Rider BB Gun" will be listed before "Daisy Red Rider BB Gun."
    Last edited by jadebox; 9 Nov 2022 at 07:30 PM.

  5. #25
    Join Date
    Apr 2019
    Posts
    242
    Plugin Contributions
    0

    Default Re: Improving search results

    I see. Thanks for your explanation.

    I changed the related code to the following and it doesn't work neither...I just want the basic keyword match.

    Code:
                                
    default:
                                    $in_name_select1 .= "pd.products_name LIKE ':keywords'";
                                    $in_name_select1 = $db->bindVars($in_name_select1, ':keywords', $current_keyword, 'noquotestring');
                                    $in_name_select2 .= "pd.products_description LIKE ':keywords'";
                                    $in_name_select2 = $db->bindVars($in_name_select2, ':keywords', $current_keyword, 'noquotestring');
                                    break;

  6. #26
    Join Date
    Jul 2009
    Posts
    14
    Plugin Contributions
    1

    Default Re: Improving search results

    I would recommend going back to the original code from GitHub and getting it to work before trying to change it. I apologize that I haven't tried torvista's code, but I don't see any obvious reason that it wouldn't work. My guess is that you might not have installed the file in the right folder of your store

    There's a support thread for the code at:

    https://www.zen-cart.com/showthread....Support-Thread

  7. #27
    Join Date
    Apr 2019
    Posts
    242
    Plugin Contributions
    0

    Default Re: Improving search results

    Hi @jadebox, thanks for your suggestion. I will do some tests to make the original code work at first then....

  8. #28
    Join Date
    Aug 2007
    Location
    Gijón, Asturias, Spain
    Posts
    2,571
    Plugin Contributions
    30

    Default Re: Improving search results

    To muddy the waters further, this thread is related, for those with the time to experiment:
    https://github.com/zencart/zencart/issues/5369

    I think there is certainly scope to use subqueries in this as described in the comments, but I am just not finding the time...
    Steve
    github.com/torvista: Spanish Language Pack, Google reCaptcha, Structured Data, Multiple Copy-Move-Delete, Image Checker, BackupMySQL Admin/Auto...

  9. #29
    Join Date
    Apr 2007
    Location
    Vancouver, Canada
    Posts
    1,547
    Plugin Contributions
    81

    Default Re: Improving search results

    I recommend looking at Elastic Search for improving the search functionality. We are using it in both zen cart and non-Zen Cart implementations with great success. You can see a zen cart example at redlinestands.com.

  10. #30
    Join Date
    Apr 2019
    Posts
    242
    Plugin Contributions
    0

    Default Re: Improving search results

    Quote Originally Posted by numinix View Post
    I recommend looking at Elastic Search for improving the search functionality. We are using it in both zen cart and non-Zen Cart implementations with great success. You can see a zen cart example at redlinestands.com.
    Hi @numinix, thanks for your suggestion. Can you please post some links for the Elastic Search? Is there a plug-in for Zen Cart?

    I checked your example link and its search function is too slow. It takes me about 7-8s to load, when I hit the "search" button every time. Also, if I search keyword "2 POST LIFT", the first 10 results don't have "2 POST LIFT" in their titles...

 

 
Page 3 of 4 FirstFirst 1234 LastLast

Similar Threads

  1. v154 Improving search box results on main page
    By cahoca in forum General Questions
    Replies: 2
    Last Post: 24 Jan 2016, 04:26 PM
  2. Improving Search Speed
    By jmcdougal in forum General Questions
    Replies: 0
    Last Post: 28 Jan 2011, 06:27 PM
  3. Improving Site Search
    By mutualadvantage in forum General Questions
    Replies: 1
    Last Post: 18 Feb 2008, 10:47 PM
  4. Replies: 8
    Last Post: 5 Dec 2006, 10:52 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR