对于text文本进行分词查询
如果是docker生成的容器数据库
进入docker容器
需要在里面安装以下步骤
1.先把/etc/apt/source.list 的镜像改为国内
deb https://mirrors.tencent.com/debian/ bullseye main non-free contribdeb-src https://mirrors.tencent.com/debian/ bullseye main non-free contribdeb https://mirrors.tencent.com/debian-security/ bullseye-security maindeb-src https://mirrors.tencent.com/debian-security/ bullseye-security maindeb https://mirrors.tencent.com/debian/ bullseye-updates main non-free contribdeb-src https://mirrors.tencent.com/debian/ bullseye-updates main non-free contribdeb https://mirrors.tencent.com/debian/ bullseye-backports main non-free contribdeb-src https://mirrors.tencent.com/debian/ bullseye-backports main non-free contrib
2.执行apt update 更新列表
3.安装gcc 和 make: apt install gcc;apt install make
4.安装pgsql的扩展包 apt install postgresql-server-dev-14 (apt search 搜索)
5.安装分词插件zhparser https://github.com/amutu/zhparser
执行完分词插件的make后
进入到数据库进行分词组件的创建
CREATE EXTENSION zhparser;CREATE TEXT SEARCH CONFIGURATION testzhcfg (PARSER = zhparser);ALTER TEXT SEARCH CONFIGURATION testzhcfg ADD MAPPING FOR n,v,a,i,e,l WITH simple;--可选的参数设定alter role all set zhparser.multi_short=on;
简单测试SELECT * FROM ts_parse('zhparser', 'hello world! 2010年保障房建设在全国范围内获全面启动,从中央到地方纷纷加大 了 保 障 房 的 建 设 和 投 入 力 度 。2011年,保障房进入了更大规模的建设阶段。住房城乡建设部党组书记、部长姜伟新去年底在全国住房城乡建设工作会议上表示,要继续推进保障性安居工程建设。');
连接Navicat查看
