better heuristic. now we find «t x m» or «f x m» in the first place
authorPierre Habouzit (MadCoder <pierre.habouzit@m4x.org>
Fri, 3 Dec 2004 10:14:52 +0000 (10:14 +0000)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Thu, 26 Jun 2008 21:26:23 +0000 (23:26 +0200)
git-archimport-id: opensource@polytechnique.org--2005/platal--mainline--0.9--patch-22

htdocs/search.php
include/search.classes.inc.php

index 871e2a4..c3fd7e5 100644 (file)
@@ -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;
index 2e2889d..2208eed 100644 (file)
@@ -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';
     }