gpt4 book ai didi

postgresql - postgres全文搜索字数统计

转载 作者:行者123 更新时间:2023-11-29 12:06:20 25 4
gpt4 key购买 nike

我一直在 postgres 中进行全文搜索,我想知道是否可以返回所有行的总字数?

假设你有

 text_col
_______
'dog'
'dog cat'
'dog bird dog'

“狗”的计数应该是四,“猫”的计数应该是一,鸟也应该是一。

现在我也将所有 tsvectors 保存到 gin 索引列中。

当然,这将跨越所有行,您可以在其中说类似的话

select max(ts_count(text_col_tsvector)) from mytable;

(这是我编造的,但我希望你能大致了解)

是否只能返回词素的计数,如果是,如何返回返回的词素的字典(或数组)。

最佳答案

怎么样:

select * from ts_stat('select text_col_tsvector from mytable')

编辑:你的意思是:

with words as (
select regexp_split_to_table(text_column , E'\\W+') as word
from mytable
)
select word, count(*) as cnt from words group by 1 order by 2 desc

?

关于postgresql - postgres全文搜索字数统计,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11678383/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com