1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How do I make "Relevance" the default?

Discussion in 'Enhanced Search Support' started by Matt777, Jan 3, 2013.

  1. Matt777

    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)
     
  2. Matt777

    Matt777 Member

    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:
     
  3. Slavik

    Slavik XenForo Moderator Staff Member

    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.
     
  4. Slavik

    Slavik XenForo Moderator Staff Member

  5. Matt777

    Matt777 Member

    I added
    Code:
    <input type="hidden" name="order" value="relevance">
    into the search_bar template, extrapolating from Jake's lead.

    Thanks Slavik you are one awesome dude. (y)
     
    william1872 and seojoseph like this.

Share This Page