summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2015-08-04 09:53:43 +0300
committerAndrew Dolgov <[email protected]>2015-08-04 09:53:43 +0300
commitb4f544d3898b1f9e43559a8d25e72a36d2f6390b (patch)
tree5a389b542a5dd526b26b4c5649350514769cac75
parent978eb545821d8f700e1f62b7da6a4ca0fc38adb8 (diff)
add some fts stuff
-rw-r--r--include/functions2.php24
1 files changed, 21 insertions, 3 deletions
diff --git a/include/functions2.php b/include/functions2.php
index df8768517..206673b7d 100644
--- a/include/functions2.php
+++ b/include/functions2.php
@@ -282,11 +282,17 @@
function search_to_sql($search) {
- $search_query_part = "";
+ /*if (DB_TYPE == "pgsql") {
+ $search_escaped = db_escape_string($search);
+
+ return array("(to_tsvector('english', SUBSTR(ttrss_entries.title, 0, 200) || ' ' || SUBSTR(content, 0, 800))
+ @@ to_tsquery('$search_escaped'))", explode(" ", $search));
+ }*/
$keywords = str_getcsv($search, " ");
$query_keywords = array();
$search_words = array();
+ $search_query_leftover = "";
foreach ($keywords as $k) {
if (strpos($k, "-") === 0) {
@@ -384,14 +390,26 @@
array_push($query_keywords, "(".SUBSTRING_FOR_DATE."(updated,1,LENGTH('$k')) $not = '$k')");
} else {
- array_push($query_keywords, "(UPPER(ttrss_entries.title) $not LIKE UPPER('%$k%')
- OR UPPER(ttrss_entries.content) $not LIKE UPPER('%$k%'))");
+ $search_query_leftover .= $k . " ";
if (!$not) array_push($search_words, $k);
+
+ /*array_push($query_keywords, "(UPPER(ttrss_entries.title) $not LIKE UPPER('%$k%')
+ OR UPPER(ttrss_entries.content) $not LIKE UPPER('%$k%'))");
+ if (!$not) array_push($search_words, $k);*/
}
}
}
+ if ($search_query_leftover) {
+ $search_query_leftover = db_escape_string($search_query_leftover);
+
+ array_push($query_keywords,
+ "(to_tsvector('simple', SUBSTR(ttrss_entries.title, 0, 200) || ' ' || SUBSTR(content, 0, 800))
+ @@ to_tsquery('$search_query_leftover'))");
+
+ }
+
$search_query_part = implode("AND", $query_keywords);
return array($search_query_part, $search_words);