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
9 USING pgroonga (id, content pgroonga_text_full_text_search_ops_v2)
10  WITH (query_allow_column = true);
11SET enable_seqscan = off;
12SET enable_indexscan = on;
13SET enable_bitmapscan = off;
14\pset format unaligned
15EXPLAIN (COSTS OFF)
16SELECT id, content
17  FROM memos
18 WHERE content &@~ ('id:1 PostgreSQL',
19                    NULL,
20                    'pgrn_index')::pgroonga_full_text_search_condition
21\g |sed -r -e "s/('.+'|ROW.+)::pgroonga/pgroonga/g"
22QUERY PLAN
23Index Scan using pgrn_index on memos
24  Index Cond: (content &@~ pgroonga_full_text_search_condition)
25(2 rows)
26\pset format aligned
27SELECT id, content
28  FROM memos
29 WHERE content &@~ ('id:1 PostgreSQL',
30                    NULL,
31                    'pgrn_index')::pgroonga_full_text_search_condition;
32 id |        content
33----+------------------------
34  1 | PostgreSQL is a RDBMS.
35(1 row)
36
37DROP TABLE memos;
38