1CREATE TABLE memos (
2  id integer,
3  content text
4);
5INSERT INTO memos VALUES (1, 'PostgreSQL is a RDBMS.');
6INSERT INTO memos VALUES (2, 'Groonga is fast full text search engine.');
7INSERT INTO memos VALUES (3, 'PGroonga is a PostgreSQL extension that uses Groonga.');
8CREATE INDEX pgrn_index ON memos USING pgroonga (content);
9SELECT pgroonga_command(
10         'object_exist ' ||
11           'Sources' || (SELECT oid
12                           FROM pg_class
13                          WHERE relname = 'pgrn_index'))::jsonb->1;
14 ?column?
15----------
16 true
17(1 row)
18
19SELECT pgroonga_command(
20         'object_exist ' ||
21           'Sources' || (SELECT relfilenode
22                           FROM pg_class
23                          WHERE relname = 'pgrn_index'))::jsonb->1;
24 ?column?
25----------
26 true
27(1 row)
28
29REINDEX INDEX pgrn_index;
30ANALYZE;
31SELECT pgroonga_command(
32         'object_exist ' ||
33           'Sources' || (SELECT oid
34                           FROM pg_class
35                          WHERE relname = 'pgrn_index'))::jsonb->1;
36 ?column?
37----------
38 false
39(1 row)
40
41SELECT pgroonga_command(
42         'object_exist ' ||
43           'Sources' || (SELECT relfilenode
44                           FROM pg_class
45                          WHERE relname = 'pgrn_index'))::jsonb->1;
46 ?column?
47----------
48 true
49(1 row)
50
51SET enable_seqscan = off;
52SET enable_indexscan = on;
53SET enable_bitmapscan = off;
54SELECT id, content
55  FROM memos
56 WHERE content %% 'PGroonga' AND content %% 'Groonga';
57 id |                        content
58----+-------------------------------------------------------
59  3 | PGroonga is a PostgreSQL extension that uses Groonga.
60(1 row)
61
62DROP TABLE memos;
63