Text:
, StopSel = ') AS highlight_author, ts_headline('jiebacfg', title, websearch_to_tsquery('jiebacfg', (SELECT q1 FROM queries)), 'StartSel = , StopSel = ') AS highlight_title, ts_headline('jiebacfg', subtitle, websearch_to_tsquery('jiebacfg', (SELECT q1 FROM queries)), 'StartSel = , StopSel = ') AS highlight_subtitle, ts_headline('jiebacfg', content, websearch_to_tsquery('jiebacfg', (SELECT q1 FROM queries)), 'StartSel = , StopSel = ') AS highlight_content, author, title, subtitle, content, full_text_search_weighted FROM sample WHERE full_text_search_weighted @@ websearch_to_tsquery('jiebacfg', (SELECT q1 FROM queries)) UNION SELECT ts_rank('{0.1, 0.2, 0.4, 1}', full_text_search_weighted, websearch_to_tsquery('jiebacfg', (SELECT q2 FROM queries))) - 0.1 AS rank, ts_headline('jiebacfg', author, websearch_to_tsquery('jiebacfg', (SELECT q2 FROM queries)), 'StartSel = , StopSel = ') AS highlight_author, ts_headline('jiebacfg', title, websearch_to_tsquery('jiebacfg', (SELECT q2 FROM queries)), 'StartSel = , StopSel = ') AS highlight_title, ts_headline('jiebacfg', subtitle, websearch_to_tsquery('jiebacfg', (SELECT q2 FROM queries)), 'StartSel = , StopSel = ') AS highlight_subtitle, ts_headline('jiebacfg', content, websearch_to_tsquery('jiebacfg', (SELECT q2 FROM queries)), 'StartSel = , StopSel = ') AS highlight_content, author, title, subtitle, content, full_text_search_weighted FROM sample WHERE full_text_search_weighted @@ websearch_to_tsquery('jiebacfg', (SELECT q2 FROM queries)) ORDER BY rank DESC LIMIT 20; "; $result = pg_query($query) or die('Query failed: ' . pg_last_error()); // Printing results in HTML echo "\n"; echo ""; while ($line = pg_fetch_array($result, null, PGSQL_ASSOC)) { echo "\t\n"; foreach ($line as $col_value) { echo "\t\t\n"; } echo "\t\n"; } echo "
rank author (hl) title (hl) subtitle (hl) content (hl) author title subtitle content TSVECTOR
$col_value
\n"; // Free resultset pg_free_result($result); // Closing connection pg_close($dbconn); } ?>