{"id":19458492,"url":"https://github.com/postgrespro/pg_trgm_pro","last_synced_at":"2025-08-23T03:08:52.674Z","repository":{"id":69542822,"uuid":"47106054","full_name":"postgrespro/pg_trgm_pro","owner":"postgrespro","description":null,"archived":false,"fork":false,"pushed_at":"2020-10-27T10:08:11.000Z","size":124,"stargazers_count":48,"open_issues_count":4,"forks_count":10,"subscribers_count":30,"default_branch":"master","last_synced_at":"2025-07-27T01:33:03.348Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/postgrespro.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-11-30T08:47:06.000Z","updated_at":"2025-06-12T18:58:35.000Z","dependencies_parsed_at":null,"dependency_job_id":"2dfa0564-4309-450c-9821-f555316bc255","html_url":"https://github.com/postgrespro/pg_trgm_pro","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/postgrespro/pg_trgm_pro","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/postgrespro%2Fpg_trgm_pro","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/postgrespro%2Fpg_trgm_pro/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/postgrespro%2Fpg_trgm_pro/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/postgrespro%2Fpg_trgm_pro/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/postgrespro","download_url":"https://codeload.github.com/postgrespro/pg_trgm_pro/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/postgrespro%2Fpg_trgm_pro/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267383903,"owners_count":24078573,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-27T02:00:11.917Z","response_time":82,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-10T17:27:19.308Z","updated_at":"2025-07-27T16:08:47.693Z","avatar_url":"https://github.com/postgrespro.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pg_trgm – text similarity measurement and index searching based on trigrams\n\n## Introduction\n\nThe pg_trgm module provides functions and operators for determining the\nsimilarity of alphanumeric text based on trigram matching, as well as index\noperator classes that support fast searching for similar strings.\n\nA trigram is a group of three consecutive characters taken from a string. We can\nmeasure the similarity of two strings by counting the number of trigrams they\nshare. This simple idea turns out to be very effective for measuring the\nsimilarity of words in many natural languages.\n\nThe original module is located in\n[GitHub](https://github.com/postgres/postgres/tree/master/contrib/pg_trgm). This\nmodule provides a new function and new operators which provide fuzzy searching\nfor word in a text.\n\n**Note**. Functions of this module and functions of pg_trgm module, which\nincluded in the PostgreSQL 9.6, are differ. Functions of this module have other\nnames and the module does not provide GUC parameters.\n\n## License\n\nThis module available from [GitHub](https://github.com/postgrespro/pg_trgm_pro)\nunder the same license as [PostgreSQL](http://www.postgresql.org/about/licence/)\nand supports PostgreSQL 9.4+.\n\n## Installation\n\nBefore build and install pg_trgm you should ensure following:\n\n* PostgreSQL version is 9.4 or higher.\n\nTypical installation procedure may look like this:\n\n    $ git clone https://github.com/postgrespro/pg_trgm_pro\n    $ cd pg_trgm_pro\n    $ make USE_PGXS=1\n    $ sudo make USE_PGXS=1 install\n    $ make USE_PGXS=1 installcheck\n    $ psql DB -c \"CREATE EXTENSION pg_trgm;\"\n\n## New functions and operators\n\nThe pg_trgm module provides the new functions.\n\n|            Function              | Returns |                      Description\n| -------------------------------- | ------- | ---------------------------------------------------\n| substring_similarity(text, text) | real    | Returns a number that indicates how similar the first string to the most similar word of the second string. The function searches in the second string a most similar word not a most similar substring. The range of the result is zero (indicating that the two strings are completely dissimilar) to one (indicating that the first string is identical to one of the word of the second string).\n| show_substring_limit()           | real    | Returns the current substring similarity threshold that is used by the **\u003c%** operator.\n| set_substring_limit(real)        | real    | Sets the current substring similarity threshold that is used by the **\u003c%** operator. The threshold must be between 0 and 1 (default is 0.6).\n\nThe module provides new operators.\n\n|    Operator    | Returns |                      Description\n| -------------- | ------- | ---------------------------------------------------\n| text \u003c% text   | boolean | Returns **true** if its arguments have a substring similarity that is greater than the current substring similarity threshold set by **set_substring_limit()**.\n\nGiST and GIN indexes support the operator **\u003c%**.\n\n## Examples\n\nLet us assume we have an **test_trgm** table:\n\n```sql\nCREATE TABLE test_trgm (t text);\n```\n\nYou can create GiST index:\n\n```sql\nCREATE INDEX trgm_idx ON test_trgm USING GIST (t gist_trgm_ops);\n```\n\nor GIN index:\n\n```sql\nCREATE INDEX trgm_idx ON test_trgm USING GIN (t gin_trgm_ops);\n```\n\nNow you can use an index on the **t** column for substring similarity. For example:\n\n```sql\nSELECT t, substring_similarity('word', t) AS sml\n  FROM test_trgm\n  WHERE 'word' \u003c% t\n  ORDER BY sml DESC, t;\n```\n\nThis will return all values in the text column that have a word which\nsufficiently similar to `word`, sorted from best match to worst. The index will be used to make this a fast operation even over very large data sets.\n\n## Authors\n\nOleg Bartunov \u003coleg@sai.msu.su\u003e\n\nTeodor Sigaev \u003cteodor@sigaev.ru\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpostgrespro%2Fpg_trgm_pro","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpostgrespro%2Fpg_trgm_pro","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpostgrespro%2Fpg_trgm_pro/lists"}