From: Pierre Habouzit (MadCoder Date: Sun, 9 Jan 2005 19:08:05 +0000 (+0000) Subject: search tweaks X-Git-Tag: xorg/old~499 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=1351045af6ce1b930dd6fdd535abe5ab8954c981;p=platal.git search tweaks git-archimport-id: opensource@polytechnique.org--2005/platal--mainline--0.9--patch-252 --- diff --git a/ChangeLog b/ChangeLog index 32c83b5..bdb1afd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -37,6 +37,9 @@ Bug/Wish : * Misc : - #65: broken links. -MC + + * Search : + - #249, #251, #253 : some tweaks to be more accurate. -MC * Validations : - #137: now possible to add comments without any action. -MC diff --git a/htdocs/search.php b/htdocs/search.php index 1e684a5..da10360 100644 --- a/htdocs/search.php +++ b/htdocs/search.php @@ -54,7 +54,7 @@ if (Env::has('quick')) { LEFT JOIN watch_nonins AS w ON (w.ni_id=u.user_id AND w.uid='.Session::getInt('uid').') '.$globals->search->result_where_statement.' WHERE '.$fields->get_where_statement().' - HAVING mark>=10 + HAVING mark>0 ORDER BY '.(logged() && Env::has('mod_date_sort') ? 'date DESC,' :'') .implode(',',array_filter(array($fields->get_order_statement(), 'u.promo DESC, NomSortKey, prenom'))).' LIMIT '.$offset->value.','.$globals->search->per_page; diff --git a/include/search.classes.inc.php b/include/search.classes.inc.php index 9673074..94922d4 100644 --- a/include/search.classes.inc.php +++ b/include/search.classes.inc.php @@ -280,10 +280,12 @@ class QuickSearch extends SField return "10 AS mark"; } $order = "0"; + $sep = "[ \\'\\-]"; foreach ($this->strings as $s) { - $order .= " + ( (u.nom='$s' OR u.epouse='$s') + (CONCAT(' ',u.nom,' ',u.epouse,' ') RLIKE '[ \\-]{$s}[ \\-]') )*100 - + ( u.nom LIKE '$s%' OR u.epouse LIKE '$s%' )*10 - + ( u.prenom LIKE '$s%' OR u.prenom LIKE '% $s%' OR u.prenom LIKE '%-$s%' )"; + $order .= " + ( (u.nom='$s' OR u.epouse='$s') + (CONCAT(' ',u.nom,' ',u.epouse,' ') RLIKE '$sep{$s}$sep') )*1000 + + ( CONCAT(' ',u.nom,' ',u.epouse,' ') RLIKE '$sep{$s}' )*100 + + ( (u.prenom = '$s') + (CONCAT(' ',u.prenom,' ') RLIKE '$sep{$s}$sep') )*10 + + ( u.prenom RLIKE '$sep{$s}' )"; } return $order.' AS mark'; }