This website uses cookies to personalize your experience. By using this website you agree to our cookie policy.

Reply To: search engine configuration

#2487
Ernest MarcinkoErnest 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: http://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.