create or replace function search_items(lang regconfig, query text)
returns table (id uuid, title text, location point, price numeric(16,2), currency_id bigint, thumbnail text)
language plpgsql
as
$$
declare
query_vector tsquery = to_tsquery(lang, query);
begin
return query
select
a.id,
a.title,
a.location,
a.price,
a.currency_id,
a.thumbnail
from item a,
lateral create_fts_vector(a.title, a.description, lang) weighted_fs_vector
where weighted_fs_vector @@ query_vector
order by ts_rank(weighted_fs_vector, query_vector)
desc;
end;
$$;
create or replace function search_items(lang regconfig, query text)
returns table (id uuid, title text, location point, price numeric(16,2), currency_id bigint, thumbnail text)
language plpgsql
as
$$
declare
query_vector tsquery = to_tsquery(lang, query);
begin
return query
select
a.id,
a.title,
a.location,
a.price,
a.currency_id,
a.thumbnail
from item a,
lateral create_fts_vector(a.title, a.description, lang) weighted_fs_vector
where weighted_fs_vector @@ query_vector
order by ts_rank(weighted_fs_vector, query_vector)
desc;
end;
$$;