improved keyword search

This commit is contained in:
Andrew Dolgov 2006-07-31 08:50:34 +01:00
parent 57bce3cdbc
commit e20c9d88c0
1 changed files with 25 additions and 5 deletions

View File

@ -1931,14 +1931,34 @@
function queryFeedHeadlines($link, $feed, $limit, $view_mode, $cat_view, $search, $search_mode, $match_on) { function queryFeedHeadlines($link, $feed, $limit, $view_mode, $cat_view, $search, $search_mode, $match_on) {
if ($search) { if ($search) {
$keywords = split(" ", $search);
$query_keywords = array();
if ($match_on == "both") { if ($match_on == "both") {
$search_query_part = "(upper(ttrss_entries.title) LIKE upper('%$search%')
OR upper(ttrss_entries.content) LIKE '%$search%') AND"; foreach ($keywords as $k) {
array_push($query_keywords, "(UPPER(ttrss_entries.title) LIKE UPPER('%$k%')
OR UPPER(ttrss_entries.content) LIKE UPPER('%$k%'))");
}
$search_query_part = implode("AND", $query_keywords) . "AND";
} else if ($match_on == "title") { } else if ($match_on == "title") {
$search_query_part = "upper(ttrss_entries.title) LIKE upper('%$search%')
AND"; foreach ($keywords as $k) {
array_push($query_keywords, "(UPPER(ttrss_entries.title) LIKE UPPER('%$k%'))");
}
$search_query_part = implode("AND", $query_keywords) . "AND";
} else if ($match_on == "content") { } else if ($match_on == "content") {
$search_query_part = "upper(ttrss_entries.content) LIKE upper('%$search%') AND";
foreach ($keywords as $k) {
array_push($query_keywords, "(UPPER(ttrss_entries.content) LIKE UPPER('%$k%'))");
}
$search_query_part = implode("AND", $query_keywords) . "AND";
} }
} else { } else {
$search_query_part = ""; $search_query_part = "";