pg_kazsearch

Kazakh full-text search extension for PostgreSQL

Overview

PackageVersionCategoryLicenseLanguage
pg_kazsearch2.3.0FTSLGPL-3.0Rust
IDExtensionBinLibLoadCreateTrustRelocSchema
2200pg_kazsearchNoYesNoYesNoNo-
Relatedpgroonga pg_tokenizer unaccent dict_xsyn hunspell_cs_cz dict_int pg_jieba pg_cjk_parser zhparser pg_bigm

Upstream 2.3.0 uses pgrx 0.17.0; PIGSTY packaging builds with pgrx 0.19.1 for PostgreSQL 16 through 18.

Version

TypeRepoVersionPG VerPackageDeps
EXTPIGSTY2.3.01817161514pg_kazsearch-
RPMPIGSTY2.3.01817161514pg_kazsearch_$v-
DEBPIGSTY2.3.01817161514postgresql-$v-pg-kazsearch-
OS / PGPG18PG17PG16PG15PG14
el8.x86_64N/AN/A
el8.aarch64N/AN/A
el9.x86_64N/AN/A
el9.aarch64N/AN/A
el10.x86_64N/AN/A
el10.aarch64
PIGSTY 2.3.0
PIGSTY 2.3.0
PIGSTY 2.3.0
N/AN/A
d12.x86_64N/AN/A
d12.aarch64
PIGSTY 2.3.0
PIGSTY 2.3.0
PIGSTY 2.3.0
N/AN/A
d13.x86_64
PIGSTY 2.3.0
PIGSTY 2.3.0
PIGSTY 2.3.0
N/AN/A
d13.aarch64
PIGSTY 2.3.0
PIGSTY 2.3.0
PIGSTY 2.3.0
N/AN/A
u22.x86_64
PIGSTY 2.3.0
PIGSTY 2.3.0
PIGSTY 2.3.0
N/AN/A
u22.aarch64
PIGSTY 2.3.0
PIGSTY 2.3.0
PIGSTY 2.3.0
N/AN/A
u24.x86_64
PIGSTY 2.3.0
PIGSTY 2.3.0
PIGSTY 2.3.0
N/AN/A
u24.aarch64
PIGSTY 2.3.0
PIGSTY 2.3.0
PIGSTY 2.3.0
N/AN/A
u26.x86_64N/AN/A
u26.aarch64
PIGSTY 2.3.0
PIGSTY 2.3.0
PIGSTY 2.3.0
N/AN/A

Build

You can build the RPM / DEB packages for pg_kazsearch using pig build:

pig build pkg pg_kazsearch         # build RPM / DEB packages

Install

You can install pg_kazsearch directly. First, make sure the PGDG and PIGSTY repositories are added and enabled:

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

Install the extension using pig or apt/yum/dnf:

pig install pg_kazsearch;          # Install for current active PG version
pig ext install -y pg_kazsearch -v 18  # PG 18
pig ext install -y pg_kazsearch -v 17  # PG 17
pig ext install -y pg_kazsearch -v 16  # PG 16
dnf install -y pg_kazsearch_18       # PG 18
dnf install -y pg_kazsearch_17       # PG 17
dnf install -y pg_kazsearch_16       # PG 16
apt install -y postgresql-18-pg-kazsearch   # PG 18
apt install -y postgresql-17-pg-kazsearch   # PG 17
apt install -y postgresql-16-pg-kazsearch   # PG 16

Create Extension:

CREATE EXTENSION pg_kazsearch;

Usage

Sources:

pg_kazsearch provides Kazakh full-text stemming for PostgreSQL 16 through 18. It installs a ready-to-use kazakh_cfg configuration and pg_kazsearch_dict dictionary. Cyrillic and supported modern Latin-script Kazakh converge to canonical Cyrillic stems so documents and queries can match across scripts.

Core Workflow

CREATE EXTENSION pg_kazsearch;

SELECT ts_lexize('pg_kazsearch_dict', 'алмаларымыздағы');
-- {алма}

SELECT to_tsvector('kazakh_cfg', 'мектептеріміздегі оқушылардың');
-- 'мектеп':1 'оқушы':2

Add a weighted stored vector and GIN index:

ALTER TABLE articles ADD COLUMN fts tsvector
GENERATED ALWAYS AS (
    setweight(to_tsvector('kazakh_cfg', title), 'A') ||
    setweight(to_tsvector('kazakh_cfg', body), 'B')
) STORED;

CREATE INDEX articles_fts_idx ON articles USING GIN (fts);

SELECT title
FROM articles
WHERE fts @@ websearch_to_tsquery('kazakh_cfg', 'президенттің жарлығы')
ORDER BY ts_rank_cd(
    fts,
    websearch_to_tsquery('kazakh_cfg', 'президенттің жарлығы')
) DESC;

Dictionary Tuning

Penalty weights can be changed at runtime:

ALTER TEXT SEARCH DICTIONARY pg_kazsearch_dict
    (w_deriv = 3.5, w_short_char = 100.0);

The default script_mode = auto detects supported modern Kazakh Latin orthography and returns Cyrillic stems. Disable Latin handling when strict Cyrillic-only behavior is required:

ALTER TEXT SEARCH DICTIONARY pg_kazsearch_dict
    (script_mode = cyrillic_only);

Upgrade and Search Caveats

  • Stemmer upgrades change index terms. After upgrading to 2.3.0, recompute stored tsvector columns or repopulate trigger-maintained vectors, then VACUUM (ANALYZE) the table.
ALTER EXTENSION pg_kazsearch UPDATE;
UPDATE articles SET title = title;
VACUUM (ANALYZE) articles;
  • Long-lived sessions opened before an upgrade should reconnect so they load the new dictionary.
  • Latin support targets the modern orthography. Mixed-script input, legacy apostrophe/acute/digraph spellings, and low-confidence ASCII tokens may remain unchanged.
  • websearch_to_tsquery uses strict AND semantics for ordinary terms. Applications that need broader recall should deliberately implement and measure a fallback query rather than silently changing all searches to OR.

Last Modified: 2026-07-30: extension update 2026-07-30 (7219c44)