新闻详情

新闻详情

首页 / 资讯中心 / 详情

中文全文检索pgroonga在HGDB-SEE V4.5.8版本编译

发布时间:2026/10/1 7:26:10来源:尧图网络
中文全文检索pgroonga在HGDB-SEE V4.5.8版本编译
PGroonga 官网https://pgroonga.github.io/DescriptionPGroonga (píːzí:lúnɡά) is a PostgreSQL extension to use Groonga as the index.PostgreSQL supports full text search against languages that use only alphabet and digit. It means that PostgreSQL doesn’t support full text search against Japanese, Chinese and so on. You can use super fast full text search feature against all languages by installing PGroonga into your PostgreSQL!一、安装相关依赖包yuminstallwgetcurltargzipgcc gcc-cmakezlib zlib-devel msgpack msgpack-devel mecab mecab-devel lz4 lz4-devel二、下载安装 git注意编译要求Git版本为 V2.7.4及以上版本wgethttps://www.kernel.org/pub/software/scm/git/git-2.7.4.tar.gz --no-check-certificatetar-vzxfgit-2.7.4.tar.gzcdgit-2.7.4/#Configure./configure --with-openssl/usr/local/openssl#编译安装makemakeinstall#打开操作系统环境变量配置文件修改环境变量vi/etc/profile#在底部加上git相关配置exportPATH$PATH:/usr/local/git-2.7.4#:wq保存source命令生效source/etc/profile#查看git版本git--version三、下载编译安装 groongaDescriptionGroonga is an open-source fulltext search engine and column store. It lets you write high-performance applications that requires fulltext search.官网https://groonga.org/编译安装https://groonga.org/docs/install/centos.html#centos-7PS下载source进行源码编译官网上的groonga-release-latest.noarch.rpm直接在本地安装会有问题可能会存在文件缺失。wgethttps://packages.groonga.org/source/groonga/groonga-13.0.9.tar.gz --no-check-certificatetar-xvzfgroonga-13.0.9.tar.gzcdgroonga-13.0.9#Configure./configure#编译Buildmake-j$(grep^processor/proc/cpuinfo|wc-l)#installsudomakeinstall#install之后执行如下命令查看当前系统安装了哪些库pkg-config --list-all#查看是否能查到groonga若没有查到groonga头文件和库文件的位置编译器无法使用需要设置PKG_CONFIG_PATH环境变量#查找groonga.pc的位置find/-namegroonga.pc#设置PKG_CONFIG_PATH环境变量exportPKG_CONFIG_PATH/usr/local/lib/pkgconfig/#查看是否可输出groongapkg-config --list-all#正常可输出groonga Groonga - An Embeddable Fulltext Search Engine四、下载安装 xxHashDescription:xxHash is an Extremely fast Hash algorithm, processing at RAM speed limits. Code is highly portable, and produces hashes identical across all platforms (little / big endian).Vcpkg用于在Windows、Linux、Mac上管理C和C库极大简化了第三方库的安装它由微软开源源码地址https://github.com/Microsoft/vcpkg最新发布版本为2023.04.15 Release它的license为MIT。Building xxHash - Using vcpkgYou can download and install xxHash using the vcpkg dependency managergitclone https://github.com/Microsoft/vcpkg.gitcdvcpkg./bootstrap-vcpkg.sh ./vcpkg integrateinstall./vcpkginstallxxhash五、下载安装 pgroongagitclone--recursivehttps://github.com/pgroonga/pgroonga.gitcdpgroongamakemakeinstall六、登录数据库psql highgo sysdbahighgo# select * from pg_available_extensions where name like %roon%;name|default_version|installed_version|comment--------------------------------------------------------------------------------------------------------------pgroonga|3.1.6|3.1.6|Super fastandalllanguages supportedfulltextsearchindexbasedonGroonga pgroonga_database|3.1.6||PGroongadatabasemanagement module highgo# create extension pgroonga;错误: 扩展pgroonga已经存在 highgo# \dx已安装扩展列表 名称|版本|架构模式|描述----------------------------------------------------------------------------------------------------------------------------------------------hg_mac|1.0|information_schema|hgdb mandatory access control withoutusingselinux hg_permission|1.0|information_schema|hg permission mysqlface|1.0|public|administrative functionsforPostgreSQL orafce|3.9|public|Functionsandoperators that emulate a subsetoffunctionsandpackagesfromthe Oracle RDBMS passwordcheck|1.0|information_schema|passwordcheck pg_buffercache|1.3|public|examine the shared buffer cache pg_stat_statements|1.7|public|track executionstatisticsofallSQLstatements executed pgroonga|3.1.6|public|Super fastandalllanguages supportedfulltextsearchindexbasedonGroonga plpgsql|1.0|pg_catalog|PL/pgSQL procedurallanguagezhfts|1.1|public|RUMindexaccess method zhparser|2.2|public|a parserforfull-textsearchofChinese(11行记录)七、使用1、启用全文搜索作为文本类型的列CREATETABLEmemos(idinteger,contenttext);CREATEINDEXpgroonga_content_indexONmemosUSINGpgroonga(content);INSERTINTOmemosVALUES(1,PostgreSQL is a relational database management system.);INSERTINTOmemosVALUES(2,Groonga is a fast full text search engine that supports all languages.);INSERTINTOmemosVALUES(3,PGroonga is a PostgreSQL extension that uses Groonga as index.);INSERTINTOmemosVALUES(4,There is groonga command.);SETenable_seqscanoff;There are the following operators to perform full text search:~LIKEILIKE~operator You canuse~operatortoperformfulltextsearchbyquery syntax suchaskeyword1ORkeyword2: highgo# SELECT * FROM memos WHERE content ~ PGroonga OR PostgreSQL;id|content--------------------------------------------------------------------1|PostgreSQLisa relationaldatabasemanagement system.3|PGroongaisa PostgreSQL extension that uses Groongaasindex.(2行记录) operator You canuse operatortoperformfulltextsearchbyone keyword: highgo# SELECT * FROM memos WHERE content engine;id|content----------------------------------------------------------------------------2|Groongaisa fastfulltextsearchenginethat supportsalllanguages.(1行记录)LIKEoperator PGroonga supportsLIKEoperator.You can perform fastfulltextsearchbyPGroonga without changing existingSQL.columnLIKE%keyword%almost equalstocolumnkeyword: highgo# SELECT * FROM memos WHERE content LIKE %engine%;id|content----------------------------------------------------------------------------2|Groongaisa fastfulltextsearchenginethat supportsalllanguages.(1行记录)2、Score匹配精度排序You can usepgroonga.scorefunction to get precision as a number. If a record is more precision against searched query, the record has more higher number.You need to add primary key column intopgroongaindex to usepgroonga.scorefunction. If you don’t add primary key column intopgroongaindex,pgroonga.scorefunction always returns0.Here is a sample schema that includes primary key into indexed columns:CREATETABLEscore_memos(idintegerPRIMARYKEY,contenttext);CREATEINDEXpgroonga_score_memos_content_indexONscore_memosUSINGpgroonga(id,content);INSERTINTOscore_memosVALUES(1,PostgreSQL is a relational database management system.);INSERTINTOscore_memosVALUES(2,Groonga is a fast full text search engine that supports all languages.);INSERTINTOscore_memosVALUES(3,PGroonga is a PostgreSQL extension that uses Groonga as index.);INSERTINTOscore_memosVALUES(4,There is groonga command.);SETenable_seqscanoff;--执行全文检索并获得分数SELECT*,pgroonga_score(tableoid,ctid)FROMscore_memosWHEREcontentPGroongaORcontentPostgreSQL;id|content|pgroonga_score------------------------------------------------------------------------------------1|PostgreSQLisa relationaldatabasemanagement system.|13|PGroongaisa PostgreSQL extension that uses Groongaasindex.|2(2行记录)--可以使用ORDER by子句中的pgroonga_score函数按精度降序对匹配的记录进行排序highgo# SELECT *, pgroonga_score(tableoid, ctid)highgo-# FROM score_memoshighgo-# WHERE content PGroonga OR content PostgreSQLhighgo-# ORDER BY pgroonga_score(tableoid, ctid) DESC;id|content|pgroonga_score------------------------------------------------------------------------------------3|PGroongaisa PostgreSQL extension that uses Groongaasindex.|21|PostgreSQLisa relationaldatabasemanagement system.|1(2行记录)更多用法详见官网https://pgroonga.github.io/tutorial/Author HGDB-QIURU
网站建设高端定制企业官网
RELATED

相关资讯

更多精彩内容,欢迎继续阅读

较早相关资讯

最新相关资讯

2026.9.30 Python Vibe Coding 实操 2026/10/1 8:34:51

2026.9.30 Python Vibe Coding 实操

考题一:Excel 报表生成脚本一、需求澄清清单类别详细说明核心目标编写 Python 脚本,自动完成销售原始数据的清洗、统计并输出标准化 Excel 报表输入文件sales_raw.xlsx,固定字段:日期、销售员、产品、数量、单价、地区&#xff1b…

阅读更多 →
RJ45水晶头线序详解:T568A/T568B一张图看懂压线逻辑 2026/10/1 8:34:44

RJ45水晶头线序详解:T568A/T568B一张图看懂压线逻辑

说实话,RJ45这玩意儿,是我入行前半年里最没面子的一道坎。别说压线了,光是把那8根五颜六色的线按顺序排进水晶头,我就练废了差不多一整盒。后来带我的师傅甩给我一张图,说“你把这图看懂了,这辈子压线都不会…

阅读更多 →
MyBatis 从入门到实战(附完整代码) 2026/10/1 8:34:38

MyBatis 从入门到实战(附完整代码)

一、引言摘要:本文面向 MyBatis 初学者,通过「基础认知 → 核心配置 → 高级特性」三阶段学习路线,带你从零搭建可运行 Demo,掌握 Mapper 代理开发、参数传递、动态 SQL、缓存机制与性能优化,并附完整可运行的 CRUD 代…

阅读更多 →
内置 4K 解码与 HDMI 输出的高集成 SoC:SSD203D 在微型投影与商显中的应用 2026/10/1 8:34:38

内置 4K 解码与 HDMI 输出的高集成 SoC:SSD203D 在微型投影与商显中的应用

微型投影、便携大屏、商显一体机与广告机这类产品,核心诉求往往是“把片源解码、画面输出和声音处理用尽量少的芯片完成”。如果还要兼顾电池供电和轻量 UI,主控的集成度直接决定板级成本与开发周期。本文以星宸(SigmaStar)SSD203…

阅读更多 →
接个大模型接口就算AI产品?传统软件设计思维真的没用了? 2026/10/1 8:34:38

接个大模型接口就算AI产品?传统软件设计思维真的没用了?

亲爱的小伙伴,如有帮助请订阅专栏!跟着老师每课一练,系统学习AI产品经理课程! 《AI产品经理入门实战》https://edu.csdn.net/course/detail/41126《Axure原型设计精品课》https://edu.csdn.net/course/detail/40420 一、接个接口…

阅读更多 →
编译原理课后习题答案使用指南:从词法分析到Flex+Bison实践 2026/10/1 8:34:25

编译原理课后习题答案使用指南:从词法分析到Flex+Bison实践

简介:《编译原理及实践》是编译技术入门到进阶的常备教材,这份PDF是配套课后习题答案,适合计算机专业学生、考研复习者以及自学编译器原理的开发者。资源围绕词法分析、语法分析、语义分析、中间代码生成、代码优化、目标代码生成与错误处理等…

阅读更多 →

今日资讯

本周资讯

本月资讯

看完文章仍有疑问?

联系尧图顾问,获取一对一建站咨询

立即免费咨询 📞 400-888-8888
📞 ✉