Skip to content

pg_jieba

Chinese full-text search parser based on cppjieba

pg_jieba · Chinese full-text search parser based on cppjieba

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
2250pg_jiebapg_jieba1.1.0FTSBSD-3-ClauseC++
AttributeHas BinaryHas LibraryNeed LoadHas DDLRelocatableTrusted
--s-d-rNoYesNoYesyesno
Package 2.0.1 ships extension version 1.1.0, vendors cppjieba commit 45809955, and fixes the LexDescr terminator allocation.

Packages

TypeRepoVersionPG Major CompatibilityPackage PatternDependencies
EXTPIGSTY1.1.019 18 17 16 15pg_jieba-
RPMPIGSTY2.0.119 18 17 16 15pg_jieba_$v-
DEBPIGSTY2.0.119 18 17 16 15postgresql-$v-pg-jieba-
Linux / PGPG19PG18PG17PG16PG15
el8.x86_64N/APIGSTY 2.0.1PIGSTY 2.0.1PIGSTY 2.0.1PIGSTY 2.0.1
el8.aarch64N/APIGSTY 2.0.1PIGSTY 2.0.1PIGSTY 2.0.1PIGSTY 2.0.1
el9.x86_64PIGSTY 2.0.1PIGSTY 2.0.1PIGSTY 2.0.1PIGSTY 2.0.1PIGSTY 2.0.1
el9.aarch64PIGSTY 2.0.1PIGSTY 2.0.1PIGSTY 2.0.1PIGSTY 2.0.1PIGSTY 2.0.1
el10.x86_64PIGSTY 2.0.1PIGSTY 2.0.1PIGSTY 2.0.1PIGSTY 2.0.1PIGSTY 2.0.1
el10.aarch64PIGSTY 2.0.1PIGSTY 2.0.1PIGSTY 2.0.1PIGSTY 2.0.1PIGSTY 2.0.1
d12.x86_64PIGSTY 2.0.1PIGSTY 2.0.1PIGSTY 2.0.1PIGSTY 2.0.1PIGSTY 2.0.1
d12.aarch64PIGSTY 2.0.1PIGSTY 2.0.1PIGSTY 2.0.1PIGSTY 2.0.1PIGSTY 2.0.1
d13.x86_64PIGSTY 2.0.1PIGSTY 2.0.1PIGSTY 2.0.1PIGSTY 2.0.1PIGSTY 2.0.1
d13.aarch64PIGSTY 2.0.1PIGSTY 2.0.1PIGSTY 2.0.1PIGSTY 2.0.1PIGSTY 2.0.1
u22.x86_64PIGSTY 2.0.1PIGSTY 2.0.1PIGSTY 2.0.1PIGSTY 2.0.1PIGSTY 2.0.1
u22.aarch64PIGSTY 2.0.1PIGSTY 2.0.1PIGSTY 2.0.1PIGSTY 2.0.1PIGSTY 2.0.1
u24.x86_64PIGSTY 2.0.1PIGSTY 2.0.1PIGSTY 2.0.1PIGSTY 2.0.1PIGSTY 2.0.1
u24.aarch64PIGSTY 2.0.1PIGSTY 2.0.1PIGSTY 2.0.1PIGSTY 2.0.1PIGSTY 2.0.1
u26.x86_64PIGSTY 2.0.1PIGSTY 2.0.1PIGSTY 2.0.1PIGSTY 2.0.1PIGSTY 2.0.1
u26.aarch64PIGSTY 2.0.1PIGSTY 2.0.1PIGSTY 2.0.1PIGSTY 2.0.1PIGSTY 2.0.1
PackageVersionOSORGSIZEFile URL
pg_jieba_182.0.1el8.x86_64pigsty3.7 MiBpg_jieba_18-2.0.1-2PGSTY.el8.x86_64.rpm
pg_jieba_182.0.1el8.aarch64pigsty3.7 MiBpg_jieba_18-2.0.1-2PGSTY.el8.aarch64.rpm
pg_jieba_182.0.1el9.x86_64pigsty3.1 MiBpg_jieba_18-2.0.1-2PGSTY.el9.x86_64.rpm
pg_jieba_182.0.1el9.aarch64pigsty3.1 MiBpg_jieba_18-2.0.1-2PGSTY.el9.aarch64.rpm
pg_jieba_182.0.1el10.x86_64pigsty3.2 MiBpg_jieba_18-2.0.1-2PGSTY.el10.x86_64.rpm
pg_jieba_182.0.1el10.aarch64pigsty3.1 MiBpg_jieba_18-2.0.1-2PGSTY.el10.aarch64.rpm
postgresql-18-pg-jieba2.0.1d12.x86_64pigsty3.0 MiBpostgresql-18-pg-jieba_2.0.1-1PGSTY~bookworm_amd64.deb
postgresql-18-pg-jieba2.0.1d12.aarch64pigsty3.0 MiBpostgresql-18-pg-jieba_2.0.1-1PGSTY~bookworm_arm64.deb
postgresql-18-pg-jieba2.0.1d13.x86_64pigsty3.0 MiBpostgresql-18-pg-jieba_2.0.1-1PGSTY~trixie_amd64.deb
postgresql-18-pg-jieba2.0.1d13.aarch64pigsty3.0 MiBpostgresql-18-pg-jieba_2.0.1-1PGSTY~trixie_arm64.deb
postgresql-18-pg-jieba2.0.1u22.x86_64pigsty3.1 MiBpostgresql-18-pg-jieba_2.0.1-1PGSTY~jammy_amd64.deb
postgresql-18-pg-jieba2.0.1u22.aarch64pigsty3.1 MiBpostgresql-18-pg-jieba_2.0.1-1PGSTY~jammy_arm64.deb
postgresql-18-pg-jieba2.0.1u24.x86_64pigsty3.1 MiBpostgresql-18-pg-jieba_2.0.1-1PGSTY~noble_amd64.deb
postgresql-18-pg-jieba2.0.1u24.aarch64pigsty3.1 MiBpostgresql-18-pg-jieba_2.0.1-1PGSTY~noble_arm64.deb
postgresql-18-pg-jieba2.0.1u26.x86_64pigsty3.1 MiBpostgresql-18-pg-jieba_2.0.1-1PGSTY~resolute_amd64.deb
postgresql-18-pg-jieba2.0.1u26.aarch64pigsty3.1 MiBpostgresql-18-pg-jieba_2.0.1-1PGSTY~resolute_arm64.deb
PackageVersionOSORGSIZEFile URL
pg_jieba_172.0.1el8.x86_64pigsty3.7 MiBpg_jieba_17-2.0.1-2PGSTY.el8.x86_64.rpm
pg_jieba_172.0.1el8.aarch64pigsty3.7 MiBpg_jieba_17-2.0.1-2PGSTY.el8.aarch64.rpm
pg_jieba_172.0.1el9.x86_64pigsty3.1 MiBpg_jieba_17-2.0.1-2PGSTY.el9.x86_64.rpm
pg_jieba_172.0.1el9.aarch64pigsty3.1 MiBpg_jieba_17-2.0.1-2PGSTY.el9.aarch64.rpm
pg_jieba_172.0.1el10.x86_64pigsty3.2 MiBpg_jieba_17-2.0.1-2PGSTY.el10.x86_64.rpm
pg_jieba_172.0.1el10.aarch64pigsty3.1 MiBpg_jieba_17-2.0.1-2PGSTY.el10.aarch64.rpm
postgresql-17-pg-jieba2.0.1d12.x86_64pigsty3.0 MiBpostgresql-17-pg-jieba_2.0.1-1PGSTY~bookworm_amd64.deb
postgresql-17-pg-jieba2.0.1d12.aarch64pigsty3.0 MiBpostgresql-17-pg-jieba_2.0.1-1PGSTY~bookworm_arm64.deb
postgresql-17-pg-jieba2.0.1d13.x86_64pigsty3.0 MiBpostgresql-17-pg-jieba_2.0.1-1PGSTY~trixie_amd64.deb
postgresql-17-pg-jieba2.0.1d13.aarch64pigsty3.0 MiBpostgresql-17-pg-jieba_2.0.1-1PGSTY~trixie_arm64.deb
postgresql-17-pg-jieba2.0.1u22.x86_64pigsty3.1 MiBpostgresql-17-pg-jieba_2.0.1-1PGSTY~jammy_amd64.deb
postgresql-17-pg-jieba2.0.1u22.aarch64pigsty3.1 MiBpostgresql-17-pg-jieba_2.0.1-1PGSTY~jammy_arm64.deb
postgresql-17-pg-jieba2.0.1u24.x86_64pigsty3.1 MiBpostgresql-17-pg-jieba_2.0.1-1PGSTY~noble_amd64.deb
postgresql-17-pg-jieba2.0.1u24.aarch64pigsty3.1 MiBpostgresql-17-pg-jieba_2.0.1-1PGSTY~noble_arm64.deb
postgresql-17-pg-jieba2.0.1u26.x86_64pigsty3.1 MiBpostgresql-17-pg-jieba_2.0.1-1PGSTY~resolute_amd64.deb
postgresql-17-pg-jieba2.0.1u26.aarch64pigsty3.1 MiBpostgresql-17-pg-jieba_2.0.1-1PGSTY~resolute_arm64.deb
PackageVersionOSORGSIZEFile URL
pg_jieba_162.0.1el8.x86_64pigsty3.7 MiBpg_jieba_16-2.0.1-2PGSTY.el8.x86_64.rpm
pg_jieba_162.0.1el8.aarch64pigsty3.7 MiBpg_jieba_16-2.0.1-2PGSTY.el8.aarch64.rpm
pg_jieba_162.0.1el9.x86_64pigsty3.1 MiBpg_jieba_16-2.0.1-2PGSTY.el9.x86_64.rpm
pg_jieba_162.0.1el9.aarch64pigsty3.1 MiBpg_jieba_16-2.0.1-2PGSTY.el9.aarch64.rpm
pg_jieba_162.0.1el10.x86_64pigsty3.2 MiBpg_jieba_16-2.0.1-2PGSTY.el10.x86_64.rpm
pg_jieba_162.0.1el10.aarch64pigsty3.1 MiBpg_jieba_16-2.0.1-2PGSTY.el10.aarch64.rpm
postgresql-16-pg-jieba2.0.1d12.x86_64pigsty3.0 MiBpostgresql-16-pg-jieba_2.0.1-1PGSTY~bookworm_amd64.deb
postgresql-16-pg-jieba2.0.1d12.aarch64pigsty3.0 MiBpostgresql-16-pg-jieba_2.0.1-1PGSTY~bookworm_arm64.deb
postgresql-16-pg-jieba2.0.1d13.x86_64pigsty3.0 MiBpostgresql-16-pg-jieba_2.0.1-1PGSTY~trixie_amd64.deb
postgresql-16-pg-jieba2.0.1d13.aarch64pigsty3.0 MiBpostgresql-16-pg-jieba_2.0.1-1PGSTY~trixie_arm64.deb
postgresql-16-pg-jieba2.0.1u22.x86_64pigsty3.1 MiBpostgresql-16-pg-jieba_2.0.1-1PGSTY~jammy_amd64.deb
postgresql-16-pg-jieba2.0.1u22.aarch64pigsty3.1 MiBpostgresql-16-pg-jieba_2.0.1-1PGSTY~jammy_arm64.deb
postgresql-16-pg-jieba2.0.1u24.x86_64pigsty3.1 MiBpostgresql-16-pg-jieba_2.0.1-1PGSTY~noble_amd64.deb
postgresql-16-pg-jieba2.0.1u24.aarch64pigsty3.1 MiBpostgresql-16-pg-jieba_2.0.1-1PGSTY~noble_arm64.deb
postgresql-16-pg-jieba2.0.1u26.x86_64pigsty3.1 MiBpostgresql-16-pg-jieba_2.0.1-1PGSTY~resolute_amd64.deb
postgresql-16-pg-jieba2.0.1u26.aarch64pigsty3.1 MiBpostgresql-16-pg-jieba_2.0.1-1PGSTY~resolute_arm64.deb
PackageVersionOSORGSIZEFile URL
pg_jieba_152.0.1el8.x86_64pigsty3.7 MiBpg_jieba_15-2.0.1-2PGSTY.el8.x86_64.rpm
pg_jieba_152.0.1el8.aarch64pigsty3.7 MiBpg_jieba_15-2.0.1-2PGSTY.el8.aarch64.rpm
pg_jieba_152.0.1el9.x86_64pigsty3.1 MiBpg_jieba_15-2.0.1-2PGSTY.el9.x86_64.rpm
pg_jieba_152.0.1el9.aarch64pigsty3.1 MiBpg_jieba_15-2.0.1-2PGSTY.el9.aarch64.rpm
pg_jieba_152.0.1el10.x86_64pigsty3.2 MiBpg_jieba_15-2.0.1-2PGSTY.el10.x86_64.rpm
pg_jieba_152.0.1el10.aarch64pigsty3.1 MiBpg_jieba_15-2.0.1-2PGSTY.el10.aarch64.rpm
postgresql-15-pg-jieba2.0.1d12.x86_64pigsty3.0 MiBpostgresql-15-pg-jieba_2.0.1-1PGSTY~bookworm_amd64.deb
postgresql-15-pg-jieba2.0.1d12.aarch64pigsty3.0 MiBpostgresql-15-pg-jieba_2.0.1-1PGSTY~bookworm_arm64.deb
postgresql-15-pg-jieba2.0.1d13.x86_64pigsty3.0 MiBpostgresql-15-pg-jieba_2.0.1-1PGSTY~trixie_amd64.deb
postgresql-15-pg-jieba2.0.1d13.aarch64pigsty3.0 MiBpostgresql-15-pg-jieba_2.0.1-1PGSTY~trixie_arm64.deb
postgresql-15-pg-jieba2.0.1u22.x86_64pigsty3.1 MiBpostgresql-15-pg-jieba_2.0.1-1PGSTY~jammy_amd64.deb
postgresql-15-pg-jieba2.0.1u22.aarch64pigsty3.1 MiBpostgresql-15-pg-jieba_2.0.1-1PGSTY~jammy_arm64.deb
postgresql-15-pg-jieba2.0.1u24.x86_64pigsty3.1 MiBpostgresql-15-pg-jieba_2.0.1-1PGSTY~noble_amd64.deb
postgresql-15-pg-jieba2.0.1u24.aarch64pigsty3.1 MiBpostgresql-15-pg-jieba_2.0.1-1PGSTY~noble_arm64.deb
postgresql-15-pg-jieba2.0.1u26.x86_64pigsty3.1 MiBpostgresql-15-pg-jieba_2.0.1-1PGSTY~resolute_amd64.deb
postgresql-15-pg-jieba2.0.1u26.aarch64pigsty3.1 MiBpostgresql-15-pg-jieba_2.0.1-1PGSTY~resolute_arm64.deb

Source

pig build pkg pg_jieba;		# build rpm/deb

Install

Make sure PGDG and PIGSTY repo available:

pig repo add pgsql -u   # add both repo and update cache

Install this extension with pig:

pig install pg_jieba;		# install by package name

pig install pg_jieba -v 19;   # install for PG 19
pig install pg_jieba -v 18;   # install for PG 18
pig install pg_jieba -v 17;   # install for PG 17
pig install pg_jieba -v 16;   # install for PG 16
pig install pg_jieba -v 15;   # install for PG 15

Create this extension with:

CREATE EXTENSION pg_jieba;

Usage

Sources:

pg_jieba adds Jieba-based Chinese word segmentation to PostgreSQL full-text search. The upstream v2.0.1 source release installs SQL extension version 1.1.0, as recorded by its control file. It provides separate document and query parsers plus ready-to-use text-search configurations.

Core Workflow

CREATE EXTENSION pg_jieba;

SELECT to_tsvector(
    'jiebacfg',
    '小明硕士毕业于中国科学院计算所,后在日本京都大学深造'
);

SELECT plainto_tsquery('jiebaqry', '云计算专家');

Use jiebacfg to build searchable document vectors and jiebaqry to segment user queries:

ALTER TABLE articles
ADD COLUMN search_vector tsvector
GENERATED ALWAYS AS (to_tsvector('jiebacfg', body)) STORED;

CREATE INDEX articles_search_idx
ON articles USING GIN (search_vector);

SELECT title
FROM articles
WHERE search_vector @@ plainto_tsquery('jiebaqry', '中文全文检索');

Object Index

  • jieba: document text-search parser.
  • jiebaqry: query-oriented text-search parser.
  • jiebacfg: document text-search configuration using jieba and jieba_stem.
  • jiebaqry: text-search configuration of the same name using the query parser.
  • jieba_stem: simple dictionary with Jieba stop words used for the parser’s token categories.

Custom Dictionary and Caveats

Upstream reads a custom dictionary named jieba.user.dict.utf8 from PostgreSQL’s tsearch_data directory. Entries may contain a word and optional part-of-speech tag:

云计算
韩玉鉴赏
蓝翔 nz
  • The v2.x source requires a C++11-capable compiler because of its bundled cppjieba dependency.
  • Upstream’s published compatibility testing is old and limited. Build and regression-test the package against the exact PostgreSQL major version used in production.
  • Changing dictionaries changes tokenization. Recompute stored tsvector values and rebuild dependent indexes when dictionary output changes.

Table reader