Use keyword search by default

Change the default search mode such that packages that contain all of
the space-separated search terms are returned. For example, the query

    image edit "command line"

returns all packages where "image", "edit" and "command line" occurs in
the package name or description. This is much more convenient and
general than a simple substring search (one can still perform a
substring search by quoting the whole search term).

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
This commit is contained in:
Lukas Fleischer 2015-05-22 12:06:46 +02:00
parent 913367606e
commit 20b838a90c

View file

@ -601,9 +601,11 @@ function pkg_search_page($SID="") {
} }
else { else {
/* Search by name and description (default). */ /* Search by name and description (default). */
$K = "%" . addcslashes($_GET['K'], '%_') . "%"; foreach (str_getcsv($_GET['K'], ' ') as $term) {
$q_where .= "AND (Packages.Name LIKE " . $dbh->quote($K) . " OR "; $term = "%" . addcslashes($term, '%_') . "%";
$q_where .= "Description LIKE " . $dbh->quote($K) . ") "; $q_where .= "AND (Packages.Name LIKE " . $dbh->quote($term) . " OR ";
$q_where .= "Description LIKE " . $dbh->quote($term) . ") ";
}
} }
} }