File: pg_trgm.sql

package info (click to toggle)
sqlfluff 3.5.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 34,000 kB
  • sloc: python: 106,131; sql: 34,188; makefile: 52; sh: 8
file content (32 lines) | stat: -rw-r--r-- 1,010 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
-- PostgreSQL pg_trgm similarity operators
-- https://www.postgresql.org/docs/current/pgtrgm.html

-- text % text → boolean (similarity)
SELECT 'abc' % 'abd';

-- text <% text → boolean (word_similarity)
SELECT 'word' <% 'some word here';

-- text %> text → boolean (word_similarity reverse)
SELECT 'some word here' %> 'word';

-- text <<% text → boolean (strict_word_similarity)
SELECT 'text' <<% 'some text example';

-- text %>> text → boolean (strict_word_similarity reverse)
SELECT 'some text example' %>> 'text';

-- text <-> text → real (similarity distance)
SELECT 'str1' <-> 'str2';

-- text <<-> text → real (word_similarity distance)
SELECT 'item' <<-> 'some item value';

-- text <->> text → real (word_similarity distance reverse)
SELECT 'some item value' <->> 'item';

-- text <<<-> text → real (strict_word_similarity distance)
SELECT 'name' <<<-> 'some name field';

-- text <->>> text → real (strict_word_similarity distance reverse)
SELECT 'some name field' <->>> 'name';