1
0
mirror of https://git.tt-rss.org/git/tt-rss.git synced 2025-12-13 19:55:55 +00:00

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
This commit is contained in:
Andrew Dolgov
2019-04-30 14:39:08 +03:00
parent 1cd9b3c866
commit ccc0315ef0
2 changed files with 40 additions and 21 deletions

View File

@@ -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))");
}
}