pg_tokenizer
pg_tokenizer : Tokenizers for full-text search
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 2170 | pg_tokenizer | pg_tokenizer | 0.1.1 |
FTS | Apache-2.0 | Rust |
| Attribute | Has Binary | Has Library | Need Load | Has DDL | Relocatable | Trusted |
|---|---|---|---|---|---|---|
| --sLd-- | No | Yes | Yes | Yes | no | no |
| Relationships | |
|---|---|
| Schemas | tokenizer_catalog |
| See Also | pgroonga pg_jieba pg_cjk_parser zhparser pg_bigm pg_tiktoken pg_tiktoken_c unaccent dict_xsyn dict_int hunspell_cs_cz pg_kazsearch |
Packages
| Type | Repo | Version | PG Major Compatibility | Package Pattern | Dependencies |
|---|---|---|---|---|---|
| EXT | PIGSTY | 0.1.1 |
18 17 16 15 14 | pg_tokenizer |
- |
| RPM | PIGSTY | 0.1.1 |
18 17 16 15 14 | pg_tokenizer_$v |
- |
| DEB | PIGSTY | 0.1.1 |
18 17 16 15 14 | postgresql-$v-pg-tokenizer |
- |
| Linux / PG | PG18 | PG17 | PG16 | PG15 | PG14 |
|---|---|---|---|---|---|
| el8.x86_64 | PIGSTY 0.1.1 | PIGSTY 0.1.1 | PIGSTY 0.1.1 | PIGSTY 0.1.1 | PIGSTY 0.1.1 |
| el8.aarch64 | PIGSTY 0.1.1 | PIGSTY 0.1.1 | PIGSTY 0.1.1 | PIGSTY 0.1.1 | PIGSTY 0.1.1 |
| el9.x86_64 | PIGSTY 0.1.1 | PIGSTY 0.1.1 | PIGSTY 0.1.1 | PIGSTY 0.1.1 | PIGSTY 0.1.1 |
| el9.aarch64 | PIGSTY 0.1.1 | PIGSTY 0.1.1 | PIGSTY 0.1.1 | PIGSTY 0.1.1 | PIGSTY 0.1.1 |
| el10.x86_64 | PIGSTY 0.1.1 | PIGSTY 0.1.1 | PIGSTY 0.1.1 | PIGSTY 0.1.1 | PIGSTY 0.1.1 |
| el10.aarch64 | PIGSTY 0.1.1 | PIGSTY 0.1.1 | PIGSTY 0.1.1 | PIGSTY 0.1.1 | PIGSTY 0.1.1 |
| d12.x86_64 | PIGSTY 0.1.1 | PIGSTY 0.1.1 | PIGSTY 0.1.1 | PIGSTY 0.1.1 | PIGSTY 0.1.1 |
| d12.aarch64 | PIGSTY 0.1.1 | PIGSTY 0.1.1 | PIGSTY 0.1.1 | PIGSTY 0.1.1 | PIGSTY 0.1.1 |
| d13.x86_64 | PIGSTY 0.1.1 | PIGSTY 0.1.1 | PIGSTY 0.1.1 | PIGSTY 0.1.1 | PIGSTY 0.1.1 |
| d13.aarch64 | PIGSTY 0.1.1 | PIGSTY 0.1.1 | PIGSTY 0.1.1 | PIGSTY 0.1.1 | PIGSTY 0.1.1 |
| u22.x86_64 | PIGSTY 0.1.1 | PIGSTY 0.1.1 | PIGSTY 0.1.1 | PIGSTY 0.1.1 | PIGSTY 0.1.1 |
| u22.aarch64 | PIGSTY 0.1.1 | PIGSTY 0.1.1 | PIGSTY 0.1.1 | PIGSTY 0.1.1 | PIGSTY 0.1.1 |
| u24.x86_64 | PIGSTY 0.1.1 | PIGSTY 0.1.1 | PIGSTY 0.1.1 | PIGSTY 0.1.1 | PIGSTY 0.1.1 |
| u24.aarch64 | PIGSTY 0.1.1 | PIGSTY 0.1.1 | PIGSTY 0.1.1 | PIGSTY 0.1.1 | PIGSTY 0.1.1 |
| u26.x86_64 | PIGSTY 0.1.1 | PIGSTY 0.1.1 | PIGSTY 0.1.1 | PIGSTY 0.1.1 | PIGSTY 0.1.1 |
| u26.aarch64 | PIGSTY 0.1.1 | PIGSTY 0.1.1 | PIGSTY 0.1.1 | PIGSTY 0.1.1 | PIGSTY 0.1.1 |
Source
github.com/supervc-stack/pg_tokenizer.rs
pg_tokenizer.rs-0.1.1.tar.gz
Install
Make sure PGDG and PIGSTY repo available:
Install this extension with pig:
Config this extension to shared_preload_libraries:
Create this extension with:
Usage
Sources:
- 0.1.1 control
- Installation and preload
- Tokenizer usage
- Reference and n-grams
- Models
- Cache limitations
pg_tokenizer converts text to token IDs for search applications, commonly with VectorChord-BM25. A tokenizer combines text analysis with a vocabulary model. It requires shared preloading and installs its SQL objects in the fixed tokenizer_catalog schema.
Enable and Tokenize
Add the library to the existing preload list and restart PostgreSQL:
tokenize(text, text) returns integer token IDs, not a relevance score or one row per token. With the BM25 companion installed, the returned array can be converted to its sparse vector type.
Analyze Chinese Text
Jieba is a pre-tokenizer, not a built-in vocabulary model named jieba. Build a text analyzer and a custom model for the corpus:
The helper learns a vocabulary from the source column and creates a trigger to maintain token IDs. Use the same tokenizer/model for documents and queries. Japanese uses an explicitly created Lindera model with a configured dictionary; a bare model name from another tokenizer API is not interchangeable.
Object and Configuration Index
create_tokenizer,drop_tokenizer,tokenize: manage and execute tokenizers.create_text_analyzer,apply_text_analyzer: run character filters, pre-tokenization, and token filters.create_custom_model_tokenizer_and_trigger,create_lindera_model,create_huggingface_model: create corpus or imported models.create_stopwords,create_synonym: manage dictionaries.- Built-in models include
llmlingua2,bert_base_uncased,wiki_tocken, andgemma2b. - Version 0.1.1 adds the
ngramtoken filter;min_gramandmax_gramrange from 1 to 255, whilepreserve_originaldefaults to false. Configurations use TOML.
Upgrade and Cache Boundaries
After replacing a preloaded library, restart PostgreSQL before updating database objects. The 0.1.0-to-0.1.1 migration adds no SQL objects; behavior changes are in the library. Analyzer, model, and tokenizer objects are cached per connection, and this cache does not follow transaction isolation or rollback. Reconnect or use the relevant drop helper to clear an object retained after rollback. The extension is not relocatable after creation. It supplies tokenization; ranking and search indexes belong to its consumers.