Skip to content

Commit 1f2f573

Browse files
committed
Updates
1 parent 3de2694 commit 1f2f573

File tree

5 files changed

+19
-3
lines changed

5 files changed

+19
-3
lines changed

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,13 @@ https://github.com/cashapp/sqldelight
44

55
Snapshot version: 2.1.0-SNAPSHOT
66

7-
Support `TSVECTOR` type and `GIN` operations
7+
Support `TSVECTOR` type, `GIST` and `GIN` operations
8+
9+
The pg_trgm module provides GiST and GIN index operator classes that allow you to create an index over a text column for the purpose of very fast similarity searches
10+
11+
```sql
12+
CREATE EXTENSION pg_trgm;
13+
```
814

915
String is the input and output type for the table API for `TSVECTOR` columns
1016

src/main/kotlin/griffio/Main.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,5 @@ fun main() {
1717
sample.pgWebQueries.bodySearchable("neutrino & sun").executeAsList().also(::println)
1818
sample.pgWebQueries.titleBodySearchable("neutrino | sun").executeAsList().also(::println)
1919
sample.pgWebQueries.textSearchable("neutrino | gravity").executeAsList().also(::println)
20+
sample.pgWebQueries.regexSearch("atomic").executeAsList().also(::println)
2021
}

src/main/sqldelight/griffio/migrations/V1__Initial_version.sqm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
CREATE EXTENSION IF NOT EXISTS pg_trgm;
2+
13
CREATE TABLE pgweb (
24
title TEXT,
35
body TEXT,
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
CREATE INDEX pgweb_idx ON pgweb USING GIN (to_tsvector('english', title || ' ' || body));
22
-- create a GIN index to speed up the search
33
CREATE INDEX textsearch_idx ON pgweb USING GIN (textsearchable_index_col);
4-
5-
4+
-- The https://www.postgresql.org/docs/current/pgtrgm.html module provides GiST and GIN index operator classes that allow you to create an index over a text column for the purpose of very fast similarity searches
5+
CREATE INDEX pgweb_body_trgm ON pgweb USING GIST (body gist_trgm_ops(siglen=16));

src/main/sqldelight/griffio/queries/PgWeb.sq

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,10 @@ FROM pgweb
1818
WHERE textsearchable_index_col @@ to_tsquery(?)
1919
ORDER BY last_mod_date DESC
2020
LIMIT 10;
21+
22+
regexSearch:
23+
SELECT title
24+
FROM pgweb
25+
WHERE body LIKE '%' || ? || '%'
26+
ORDER BY last_mod_date DESC
27+
LIMIT 10;

0 commit comments

Comments
 (0)