I'd like to write a Joomla search plugin that searches two fields, title and content, for keywords, and orders the results something like title matches with content matches first, title matches only second, and content matches only third. Just getting the title matches ahead of content matches would be sufficient.
I got the following query to work to order titles that match ahead of content that matches, wonder if this is the best thing for the job on function as well as performance/efficiency. Thanks.
select a.id,a.title,a.title REGEXP 'clerk' as amatch, b.content,b.content REGEXP 'clerk' as bmatch from mytable as a left join mytable as b on a.id=b.id where a.title like '%clerk%' OR b.content like '%clerk%' ORDER BY amatch DESC,bmatch DESC