0
有序全文搜索我有一个像通过精确匹配PostgreSQL中
select * from mytable where posttext @@ to_tsquery('Intelence');
我有文本与“intelence”字与“英特尔”的查询。
我想返回关键字'Intelence'的精确匹配将在'intel'结果前排序的结果吗?
有序全文搜索我有一个像通过精确匹配PostgreSQL中
select * from mytable where posttext @@ to_tsquery('Intelence');
我有文本与“intelence”字与“英特尔”的查询。
我想返回关键字'Intelence'的精确匹配将在'intel'结果前排序的结果吗?
也许不是最优化的高性能和方式,但在order by
使用正则表达式匹配应该做你想要什么
with mytable(posttext) as(
select 'a Intelence' union all
select 'intel someIntelence' union all
select 'a intel' union all
select 'a Intelence b'
)
select *
from mytable
where posttext @@ to_tsquery('Intelence')
order by posttext ~* '(^|\s)intelence(\s|$)' desc