Difference between revisions of "Template:SearchResults"
(restored by csi_restorechanges) |
|||
Line 25: | Line 25: | ||
| {{#fetch:sql | | {{#fetch:sql | ||
| SELECT count(page_id) as count | | SELECT count(page_id) as count | ||
− | FROM page p | + | FROM page p |
− | + | LEFT JOIN content ct | |
− | + | ON p.page_latest = ct.content_id | |
− | + | LEFT JOIN pagecontent c | |
− | + | ON CONCAT('tt:', c.old_id) = ct.content_address | |
+ | WHERE textvector @@ userto_tsquery( {{#cast:text|{{{query|}}}|db}}) | ||
OR titlevector @@ userto_tsquery( {{#cast:text|{{{query|}}}|db}}) | OR titlevector @@ userto_tsquery( {{#cast:text|{{{query|}}}|db}}) | ||
− | |||
-- AND page_is_redirect = '0' | -- AND page_is_redirect = '0' | ||
AND page_namespace IN ({{{ns}}}) | AND page_namespace IN ({{{ns}}}) | ||
Line 47: | Line 47: | ||
{{#array:dataloop | {{#array:dataloop | ||
− | |{{#fetch:sql|SELECT *, ts_headline(page_text, userto_tsquery( {{#cast:text|{{{query|}}}|db}})) as snippet FROM (SELECT page_id, page_namespace, page_title as title, old_text AS page_text, 3*ts_rank(titlevector, userto_tsquery( {{#cast:text|{{{query|}}}|db}})) + ts_rank(textvector, userto_tsquery( {{#cast:text|{{{query|}}}|db}})) AS rnk FROM page p | + | |{{#fetch:sql|SELECT *, ts_headline(page_text, userto_tsquery( {{#cast:text|{{{query|}}}|db}})) as snippet FROM (SELECT page_id, page_namespace, page_title as title, old_text AS page_text, 3*ts_rank(titlevector, userto_tsquery( {{#cast:text|{{{query|}}}|db}})) + ts_rank(textvector, userto_tsquery( {{#cast:text|{{{query|}}}|db}})) AS rnk |
− | + | FROM page p | |
+ | LEFT JOIN content ct | ||
+ | ON p.page_latest = ct.content_id | ||
+ | LEFT JOIN pagecontent c | ||
+ | ON CONCAT('tt:', c.old_id) = ct.content_address | ||
+ | WHERE (textvector @@ userto_tsquery( {{#cast:text|{{{query|}}}|db}}) OR titlevector @@ userto_tsquery( {{#cast:text|{{{query|}}}|db}})) AND page_is_redirect = '0' AND page_namespace IN | ||
({{{ns}}}) ORDER BY rnk DESC, page_namespace ASC,page_id desc LIMIT {{{next}}} OFFSET {{{offset}}}) as tab }} | ({{{ns}}}) ORDER BY rnk DESC, page_namespace ASC,page_id desc LIMIT {{{next}}} OFFSET {{{offset}}}) as tab }} | ||
|each = {{#ifeq:{{{:#:}}}|{{{limit}}}|| | |each = {{#ifeq:{{{:#:}}}|{{{limit}}}|| |
Latest revision as of 01:14, 11 February 2021