Fixes #2168 Postgres errors in search.php and useless order by clause