search tweaks
authorPierre Habouzit (MadCoder <pierre.habouzit@m4x.org>
Sun, 9 Jan 2005 19:08:05 +0000 (19:08 +0000)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Thu, 26 Jun 2008 21:27:19 +0000 (23:27 +0200)
git-archimport-id: opensource@polytechnique.org--2005/platal--mainline--0.9--patch-252

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

index 32c83b5..bdb1afd 100644 (file)
--- 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
index 1e684a5..da10360 100644 (file)
@@ -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;
index 9673074..94922d4 100644 (file)
@@ -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';
     }