Hi,
I'm not sure if this is related but currently I'm also looking into a problem where the search does not find matching entries and I'm also running PostgreSQL (8.4.2). In my case I narrowed it down to the case where more than one word is entered into the search form. Are you using multiple words in the search form?
It seams that with tsearch a search for 'foo bar' will basically lead to the following function evaluation:
Code: Select all
s9y@prd=> select to_tsquery('foo bar');
ERROR: syntax error in tsquery: "foo bar"
The full text search expects the argument to to_tsquery to be words and operators and not a string with spaces in it. I came up with the following patch that should improve full text search:
Code: Select all
*** functions_entries.inc.php.orig Wed Nov 25 21:41:43 2009
--- functions_entries.inc.php Sun May 2 16:09:57 2010
***************
*** 761,771 ****
WHERE routine_name LIKE 'to_tsvector'
AND specific_catalog = '" . $serendipity['dbName'] . "'");
if (is_array($r) && $r[0]['counter'] > 0) {
! $term = str_replace('&', '&', $term);
$cond['find_part'] = "(
! to_tsvector('english', title) @@to_tsquery('$term') OR
! to_tsvector('english', body) @@to_tsquery('$term') OR
! to_tsvector('english', extended) @@to_tsquery('$term')
)";
} else {
$cond['find_part'] = "(title ILIKE '%$term%' OR body ILIKE '%$term%' OR extended ILIKE '%$term%')";
--- 761,772 ----
WHERE routine_name LIKE 'to_tsvector'
AND specific_catalog = '" . $serendipity['dbName'] . "'");
if (is_array($r) && $r[0]['counter'] > 0) {
! $term = html_entity_decode($term, ENT_QUOTES);
! $term = trim(strtr($term, "'\"", " "));
! $term = preg_replace('/ +/', "|", $term);
$cond['find_part'] = "(
! to_tsvector('english', coalesce(title,'')||coalesce(body,'')||coalesce(extended,''))
! @@ to_tsquery('$term')
)";
} else {
$cond['find_part'] = "(title ILIKE '%$term%' OR body ILIKE '%$term%' OR extended ILIKE '%$term%')";
A careful review is advised
Regards,
Stefan