Reply To: search engine configuration

#2487

Ernest Marcinko
Keymaster

Hi!

I could not enter with the credentials, perhaps my IP is restricted after all.

But I think I might found a quick solution for your request.

0. Turn off fulltext search if you are using it: https://i.imgur.com/1BcUDJ5.png

1. Open up the plugins/ajax-search-pro/includes/search_content.class.php file and go to line 52, where you should see this:

            /*----------------------- Title query ---------------------------*/
            if ($options['set_intitle']) {
                $words = $options['set_exactonly']==1?$s:$_si;
                $parts[] = "(lower($wpdb->posts.post_title) REGEXP '$words')";
                $relevance_parts[] = "(case when
                (lower($wpdb->posts.post_title) REGEXP '$words')
                 then $searchData[titleweight] else 0 end)";
                $relevance_parts[] = "(case when
                (lower($wpdb->posts.post_title) REGEXP '$s')
                 then $searchData[etitleweight] else 0 end)";
            }
            /*---------------------------------------------------------------*/

2. Replace that code with this:

            /*----------------------- Title query ---------------------------*/
            if ($options['set_intitle']) {
                $words = $options['set_exactonly']==1?$s:$_si;
                $parts[] = "(lower($wpdb->posts.post_title) REGEXP '$words')";
                $relevance_parts[] = "(case when
                (lower($wpdb->posts.post_title) REGEXP '$words')
                 then $searchData[titleweight] else 0 end)";
                /*$relevance_parts[] = "(case when
                (lower($wpdb->posts.post_title) REGEXP '$s')
                 then $searchData[etitleweight] else 0 end)"; */
                
                // The first word relevance is higher 
                if (count($_s)>1) 
                  $relevance_parts[] = "(case when
                  (lower($wpdb->posts.post_title) REGEXP '".$_s[0]."')
                   then $searchData[etitleweight] else 0 end)";
            }
            /*---------------------------------------------------------------*/

This modification will give the first search word higher priority, thus the order of the results will change.

Best,
Ernest Marcinko

If you like my products, don't forget to rate them on codecanyon :)