当我使用websearch_to_tsquery并搜索类似于to_tsvector('english', description) @@ websearch_to_tsquery('virtual reality')的东西时,我会得到很多结果。当我在描述中添加一个不存在的单词时,它会得到0,例如where to_tsvector('english', description) @@ websearch_to_tsquery('virtual reality fsdfasjkwnejkfb')
我如何才能得到最接近的匹配结果与所有单词匹配?
发布于 2022-03-10 15:11:16
因此,在尝试了相当长的一段时间后,我发现在我的示例中,to_tsquery函数需要配置参数,以便在明显更接近匹配时返回一个值而不是0。
to_tsquery([ config regconfig, ] querytext text) returns tsquery我是如何使用它的:
select ts_rank_cd(to_tsvector('english', 'ring the police'), to_tsquery('english', 'police'))
select ts_rank_cd(to_tsvector('english', 'ring the police'), to_tsquery('english', 'police | xyzz'))上面的两个函数返回0.1,而下面的函数返回0
select ts_rank_cd(to_tsvector('english', 'ring the police'), to_tsquery('police'))我敢肯定这也是你的案子里缺少的
https://stackoverflow.com/questions/69868567
复制相似问题