From: Pierre Habouzit (MadCoder Date: Fri, 3 Dec 2004 10:14:52 +0000 (+0000) Subject: better heuristic. now we find «t x m» or «f x m» in the first place X-Git-Tag: xorg/old~719 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=134388db115125b2dbb673ea28198859f60973aa;p=platal.git better heuristic. now we find «t x m» or «f x m» in the first place git-archimport-id: opensource@polytechnique.org--2005/platal--mainline--0.9--patch-22 --- diff --git a/htdocs/search.php b/htdocs/search.php index 871e2a4..c3fd7e5 100644 --- a/htdocs/search.php +++ b/htdocs/search.php @@ -54,7 +54,7 @@ if (isset($_REQUEST['quick'])) { LEFT JOIN watch_nonins AS w ON (w.ni_id=u.user_id AND w.uid='.((array_key_exists('uid',$_SESSION))?$_SESSION['uid']:0).') '.$globals->search->result_where_statement.' WHERE '.$fields->get_where_statement().' - HAVING mark>0 + HAVING mark>=10 ORDER BY '.(logged() && !empty($_REQUEST['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 2e2889d..2208eed 100644 --- a/include/search.classes.inc.php +++ b/include/search.classes.inc.php @@ -278,11 +278,13 @@ class QuickSearch extends SField function get_mark_statement() { if (empty($this->strings)) { - return "1 AS mark"; + return "10 AS mark"; } $order = "0"; foreach ($this->strings as $s) { - $order .= " + (u.nom='$s' OR u.epouse='$s')*100 + (u.prenom='$s')*10 + (u.nom LIKE '$s%' OR u.epouse LIKE '$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%' )"; } return $order.' AS mark'; }