pg_kazsearch
Overview
| Package | Version | Category | License | Language |
|---|---|---|---|---|
pg_kazsearch | 2.3.0 | FTS | LGPL-3.0 | Rust |
| ID | Extension | Bin | Lib | Load | Create | Trust | Reloc | Schema |
|---|---|---|---|---|---|---|---|---|
| 2200 | pg_kazsearch | No | Yes | No | Yes | No | No | - |
| Related | pgroonga 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
| Type | Repo | Version | PG Ver | Package | Deps |
|---|---|---|---|---|---|
| EXT | PIGSTY | 2.3.0 | 1817161514 | pg_kazsearch | - |
| RPM | PIGSTY | 2.3.0 | 1817161514 | pg_kazsearch_$v | - |
| DEB | PIGSTY | 2.3.0 | 1817161514 | postgresql-$v-pg-kazsearch | - |
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 storedtsvectorcolumns or repopulate trigger-maintained vectors, thenVACUUM (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_tsqueryuses 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.
Feedback
Was this page helpful?
Thanks for the feedback! Please let us know how we can improve.
Sorry to hear that. Please let us know how we can improve.