favor a perfect match
gitea/wcs/pipeline/head There was a failure building this commit Details

This commit is contained in:
Pierre Ducroquet 2024-02-28 17:37:32 +01:00
parent 311a3b403e
commit 0807aaa1ca
1 changed files with 2 additions and 1 deletions

View File

@ -1718,8 +1718,9 @@ with
tokenized as (select unnest(regexp_split_to_array($1, '\s+')) w),
super_tokenized as (
select w,
coalesce(tsquery_agg_or(plainto_tsquery(token) order by token <-> w desc), plainto_tsquery(w)) tokens
coalesce(perfect.token, tsquery_agg_or(plainto_tsquery(token) order by token <-> w desc), plainto_tsquery(w)) tokens
from tokenized
left join wcs_search_tokens perfect on token = plainto_tsquery(w)::text
left join wcs_search_tokens on token % w and w not similar to '%[0-9]{2,}%'
group by w)
select tsquery_agg_and(tokens) from super_tokenized;