How do I make "Relevance" the default?

Matt777

Member
I don't want posts sorted by "most recent", I want them sorted by "Relevance". But the user has to click on "Advanced Search" to even see the option to get "relevant" results.

I figured out I need ?o=relevance instead of ?o=date in the quick search query, but I can't figure out where and in what template to hard code that in.

Possible in the search_bar template, but I'm not sure what line I need to change.

Can anyone help me out here ? (y)
 
I want to make "relevance" the default option in the quick search box (instead of "by date"). I'm using Enhanced Search, which supports relevance ordered results.

Anyone have any ideas ? :coffee:
 
I want to make "relevance" the default option in the quick search box (instead of "by date"). I'm using Enhanced Search, which supports relevance ordered results.

Anyone have any ideas ? :coffee:

I *think* this should work.

PHP:
<?php
 
class XenES_Search_SourceHandler_RelevenceChange extends XenES_Search_SourceHandler_ElasticSearch
{
        /**
        Changes the default search order from date to relevence
    */
    public function getGeneralOrderClause($order)
    {
        if ($order == 'date')
        {
            return array(
                array('search_index', 'item_date', 'desc')
            );
        }
        else
        {
            return array(
                array('search_index', 'relevance', 'desc'),
                array('search_index', 'item_date', 'desc')
            );
        }
    }
 
}

Though I didn't check to see if the quick search box specifically defines date as its default search option.
 
Top Bottom