summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2019-04-30 14:39:08 +0300
committerAndrew Dolgov <[email protected]>2019-04-30 14:39:08 +0300
commitccc0315ef0a115fb9111823b351bbcbdf3182f66 (patch)
tree324f3d04d7392a7881c29eda1ad421ddcb3ea4d0 /include
parent1cd9b3c866e998e017873eb8b4f08864c4c5f043 (diff)
better tsquery support:
1. report query syntax errors properly 2. fall back to implicit &-joining only if no joiners are detected in user query, otherwise permit full tsquery syntax
Diffstat (limited to 'include')
-rw-r--r--include/functions.php12
1 files changed, 10 insertions, 2 deletions
diff --git a/include/functions.php b/include/functions.php
index 963018858..6dc9990e8 100644
--- a/include/functions.php
+++ b/include/functions.php
@@ -1486,11 +1486,19 @@
}
if (count($search_query_leftover) > 0) {
- $search_query_leftover = $pdo->quote(implode(" & ", $search_query_leftover));
if (DB_TYPE == "pgsql") {
+
+ // if there's no joiners consider this a "simple" search and
+ // concatenate everything with &, otherwise don't try to mess with tsquery syntax
+ if (preg_match("/[&|]/", implode(" " , $search_query_leftover))) {
+ $tsquery = $pdo->quote(implode(" ", $search_query_leftover));
+ } else {
+ $tsquery = $pdo->quote(implode(" & ", $search_query_leftover));
+ }
+
array_push($query_keywords,
- "(tsvector_combined @@ to_tsquery($search_language, $search_query_leftover))");
+ "(tsvector_combined @@ to_tsquery($search_language, $tsquery))");
}
}