0

We need to order our search results by relevance then post date, however I can't find any reference to order in the ellislab documentation:

https://ellislab.com/expressionengine/user-guide/add-ons/search/index.html

Is this even possible with the search module? If not can anyone recommend a third party addon that would allow us to do this?

Thanks!

1 Answer 1

1

Ehhh I struggled with this one an a previous project. If I remember correctly, there were a few options to do what you're looking for. First of all, these solutions came through Solspace Super Search.

First example is a little weird, but it's because I needed to create functionality that allowed people to search by dates in a various forms (like search for "September 1st" with no year, or "4/15/1880"). In your example, you could basically do this:

{exp:super_search:results
    paginate="bottom"
    {!-- other parameters --} 
    limit="10"
    orderby="event_year|event_month|event_day"
    sort="asc|asc|asc"
    relevance="title=5+body=5"}

https://solspace.com/docs/super_search/results/#orderby https://solspace.com/docs/super_search/results/#relevance

According to the docs, it sorts by relevance first, and then when you have results with the same relevance, it orders by the orderby parameter.

I'm pretty sure you can just leave the orderby parameter blank, and it defaults to sorting by entry_date. So, set your relevance, and it'll order by entry_date after that.

If you're worried, force set like this (assuming ascending date order for equally relevant results):

    orderby="entry_date"
    sort="asc"
1
  • Thanks, this is great, guess i'll be downloading super search!
    – Nick
    Aug 17, 2015 at 7:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.