Sort search results by search score?

Permalink 1 user found helpful
Hello
Is it possible to sort the search results by the reulsts score rather than the date. Currently if I search for a term using the full page index in the dashboard and sort by score the most relavent pages are top. If I search for the same term on the site however the pages appear to be in date order pushing more relavent pages down the list.

-Thanks

digirunt
 
andrew replied on at Permalink Best Answer Reply
andrew
Yes, although this does require touching code.

1. Copy concrete/blocks/search/controller.php into a new folder blocks/search/controller.php (in the empty blocks/ directory).
2. Edit controller.php. Delete the line that says

$ipl->setSimpleIndexMode(true);


3. In its place, put the line

$ipl->sortByRelevance();


That should do it.

NOTE: this makes use of the MySQL Fulltext index. If you don't tune the "stop words" for this index some searching can be really crappy. (e.g. currently "about" is in the stop words list so if you search for about you won't find anything. Lame.)
Cravener replied on at Permalink Reply
Cravener
Deleting
$ipl->setSimpleIndexMode(true);
will cause of MySQL query error if "Search block" used as "Blog Archive" list.
digirunt replied on at Permalink Reply
digirunt
Thanks for that, that's sorted it.
I'll take a look at my stop words as I've ran into issues there before.
andrew replied on at Permalink Reply
andrew
Cool. Yeah the only reason I mention stop words is because I try to search for "About" every single time when testing stuff like this and am perplexed – until I remember its on that list by default.