pg_bigm
Overview
| Package | Version | Category | License | Language |
|---|---|---|---|---|
pg_bigm | 1.2 | FTS | PostgreSQL | C |
| ID | Extension | Bin | Lib | Load | Create | Trust | Reloc | Schema |
|---|---|---|---|---|---|---|---|---|
| 2120 | pg_bigm | No | Yes | Yes | Yes | No | Yes | - |
| Related | pgroonga pg_cjk_parser pg_jieba zhparser pg_tokenizer pg_pinyin unaccent pg_trgm dict_xsyn biscuit |
|---|
Version
| Type | Repo | Version | PG Ver | Package | Deps |
|---|---|---|---|---|---|
| EXT | MIXED | 1.2 | 1817161514 | pg_bigm | - |
| RPM | PGDG | 1.2 | 1817161514 | pg_bigm_$v | - |
| DEB | PIGSTY | 1.2 | 1817161514 | postgresql-$v-pg-bigm | - |
Build
You can build the RPM / DEB packages for pg_bigm using pig build:
Install
You can install pg_bigm directly. First, make sure the PGDG and PIGSTY repositories are added and enabled:
Install the extension using pig or apt/yum/dnf:
Preload:
Create Extension:
Usage
The pg_bigm module provides full text search capability in PostgreSQL. This module allows a user to create 2-gram (bigram) index for faster full text search.
pg_bigm is released under the PostgreSQL License, a liberal Open Source license, similar to the BSD or MIT licenses.
Features
- Bigram indexing: Creates 2-gram (bigram) GIN indexes for text columns
- Faster LIKE searches: Accelerates
LIKEqueries including prefix, suffix, and substring searches - All language support: Works with any language including CJK (Chinese, Japanese, Korean) without additional configuration
- Simple API: Provides similarity search functions and operators
Functions and Operators
Functions
| Function | Return Type | Description |
|---|---|---|
likequery(text) | text | Generates a search query for full text search from a keyword |
show_bigm(text) | text[] | Shows all 2-grams in the given string |
pg_gin_pending_stats(regclass) | record | Returns the number of pages and tuples in the pending list of a GIN index |
Operators
| Operator | Description |
|---|---|
text =% text | Returns true if the similarity between the left and right operands is greater than or equal to pg_bigm.similarity_limit |
GUC Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
pg_bigm.last_update | text | - | Shows the last update date of the module (read-only) |
pg_bigm.enable_recheck | bool | on | Controls whether recheck is performed during index scan |
pg_bigm.gin_key_limit | int | 0 | Limits the maximum number of bigrams used for full text search. 0 means no limit |
pg_bigm.similarity_limit | real | 0.3 | Sets the minimum similarity threshold for the =% operator |
Examples
Basic Full Text Search
Similarity Search
Comparison with pg_trgm
pg_bigm has the following advantages over the built-in pg_trgm:
| Feature | pg_bigm | pg_trgm |
|---|---|---|
| N-gram type | 2-gram (bigram) | 3-gram (trigram) |
| Minimum search string | 1 character | 3 characters |
| Non-alphabetic languages | Full support | Limited support |
| LIKE search types | Prefix, suffix, and substring | Prefix, suffix, and substring |
For detailed documentation including advanced usage and performance tuning, see the official pg_bigm documentation.
Was this page helpful?
Thanks—your feedback helps us improve this page.
What got in the way? (optional)