feat(search): design consistency with other feed/content aggregation lists
This commit is contained in:
parent
f2bca309f5
commit
d5ace085b0
8 changed files with 87 additions and 77 deletions
|
@ -1,4 +1,6 @@
|
|||
CREATE OR REPLACE FUNCTION search_optimized_index(search_query text, page_size integer, page_offset integer, types text[])
|
||||
DROP FUNCTION IF EXISTS search_optimized_index(text, integer, integer, text[]);
|
||||
|
||||
CREATE FUNCTION search_optimized_index(search_query text, page_size integer, page_offset integer, sections text[])
|
||||
RETURNS TABLE(
|
||||
result_id integer,
|
||||
url text,
|
||||
|
@ -7,7 +9,7 @@ CREATE OR REPLACE FUNCTION search_optimized_index(search_query text, page_size i
|
|||
tags text,
|
||||
genre_name text,
|
||||
genre_url text,
|
||||
type text,
|
||||
section text,
|
||||
total_plays text,
|
||||
rank real,
|
||||
total_count bigint
|
||||
|
@ -23,17 +25,17 @@ BEGIN
|
|||
array_to_string(s.tags, ', ') AS tags,
|
||||
s.genre_name,
|
||||
s.genre_url,
|
||||
s.type,
|
||||
s.section,
|
||||
s.total_plays,
|
||||
ts_rank_cd(to_tsvector('english', s.title || ' ' || s.description || array_to_string(s.tags, ' ')), plainto_tsquery('english', search_query)) AS rank,
|
||||
COUNT(*) OVER() AS total_count
|
||||
FROM
|
||||
optimized_search_index s
|
||||
WHERE(types IS NULL
|
||||
OR s.type = ANY(types))
|
||||
WHERE(sections IS NULL
|
||||
OR s.section = ANY(sections))
|
||||
AND plainto_tsquery('english', search_query) @@ to_tsvector('english', s.title || ' ' || s.description || array_to_string(s.tags, ' '))
|
||||
ORDER BY
|
||||
s.type = 'post' DESC,
|
||||
s.section = 'post' DESC,
|
||||
s.content_date DESC NULLS LAST,
|
||||
rank DESC
|
||||
LIMIT page_size OFFSET page_offset;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue