postgresql中文分词插件安装

1.SCWS

要使用 zhparser,首先需要安装 SCWS 分词库,SCWS 是 Simple Chinese Word Segmentation 的首字母缩写(即:简易中文分词系统)GitHub

http://www.xunsearch.com/scws/down/scws-1.2.3.tar.bz2

复制代码
./configure 
make install

2.Zhparser

GitHub - amutu/zhparser: zhparser is a PostgreSQL extension for full-text search of Chinese language

复制代码
 make && make install
遇到:pgxs.mk: 没有那个文件或目录,安装postgres-devel包
找不到pg_config:可以指定PG_CONFG=/usr/pgsql-14/bin/pg_config make

3.postgresql中文检索配置

登录postgresql启用zhparser插件

create extension zhparser;

创建使用zhparser作为解析器的全文搜索的配置

-- 就是需要给zhparser解析器取一个在sql里面可以使用的名称,一下"zh"则为名称 CREATE create text search configuration chinese (parser=zhparser);

添加token映射

alter text search configuration chinese add mapping for a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z with simple;

4、全文检索使用

索引创建

create index idx_name on table_name using gin(to_tsvector('zh', field_name));

查询

SELECT * FROM table_name WHERE to_tsvector('zh', field_name) @@ 'keyword';

相关推荐
阿杰学AI3 小时前
AI核心知识91——大语言模型之 Transformer 架构(简洁且通俗易懂版)
人工智能·深度学习·ai·语言模型·自然语言处理·aigc·transformer
陈天伟教授8 小时前
人工智能应用- 语言处理:02.机器翻译:规则方法
人工智能·深度学习·神经网络·语言模型·自然语言处理·机器翻译
茶栀(*´I`*)8 小时前
【NLP入门笔记】:自然语言处理基础与文本预处理
人工智能·自然语言处理·nlp
陈天伟教授8 小时前
人工智能应用- 语言处理:01.机器翻译:人类语言的特点
人工智能·自然语言处理·机器翻译
量子-Alex9 小时前
【大模型RLHF】Training language models to follow instructions with human feedback
人工智能·语言模型·自然语言处理
陈天伟教授9 小时前
人工智能应用- 语言处理:04.统计机器翻译
人工智能·自然语言处理·机器翻译
阿杰学AI10 小时前
AI核心知识92——大语言模型之 Self-Attention Mechanism(简洁且通俗易懂版)
人工智能·ai·语言模型·自然语言处理·aigc·transformer·自注意力机制
陈天伟教授10 小时前
人工智能应用- 语言处理:03.机器翻译:规则方法
人工智能·自然语言处理·机器翻译
数研小生12 小时前
Python自然语言处理:NLTK与Gensim库
开发语言·python·自然语言处理
玄同76512 小时前
机器学习中的三大距离度量:欧式距离、曼哈顿距离、切比雪夫距离详解
人工智能·深度学习·神经网络·目标检测·机器学习·自然语言处理·数据挖掘