Navigation Menu

Skip to content

Commit

Permalink
Add "plugins" CREATE INDEX option
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Apr 26, 2017
1 parent d222601 commit 5956237
Show file tree
Hide file tree
Showing 9 changed files with 310 additions and 36 deletions.
14 changes: 14 additions & 0 deletions expected/full-text-search/text/options/plugins/one.out
@@ -0,0 +1,14 @@
CREATE TABLE memos (
id integer,
content text
);
CREATE INDEX pgrn_index ON memos
USING pgroonga (content)
WITH (plugins = 'query_expanders/tsv');
SELECT pgroonga.command('object_exist QueryExpanderTSV')::json->>1;
?column?
----------
true
(1 row)

DROP TABLE memos;
45 changes: 45 additions & 0 deletions expected/full-text-search/text/options/token-filters/custom.out
@@ -0,0 +1,45 @@
CREATE TABLE memos (
id integer,
content text
);
INSERT INTO memos VALUES (1, 'It works.');
INSERT INTO memos VALUES (2, 'I work.');
INSERT INTO memos VALUES (3, 'I worked.');
CREATE INDEX pgrn_index ON memos
USING pgroonga (content)
WITH (plugins = 'token_filters/stem',
token_filters = 'TokenFilterStem');
SET enable_seqscan = off;
SET enable_indexscan = on;
SET enable_bitmapscan = off;
SELECT id, content
FROM memos
WHERE content %% 'works';
id | content
----+-----------
1 | It works.
2 | I work.
3 | I worked.
(3 rows)

SELECT id, content
FROM memos
WHERE content %% 'work';
id | content
----+-----------
1 | It works.
2 | I work.
3 | I worked.
(3 rows)

SELECT id, content
FROM memos
WHERE content %% 'worked';
id | content
----+-----------
1 | It works.
2 | I work.
3 | I worked.
(3 rows)

DROP TABLE memos;
38 changes: 38 additions & 0 deletions expected/full-text-search/text/options/token-filters/empty.out
@@ -0,0 +1,38 @@
CREATE TABLE memos (
id integer,
content text
);
INSERT INTO memos VALUES (1, 'It works.');
INSERT INTO memos VALUES (2, 'I work.');
INSERT INTO memos VALUES (3, 'I worked.');
CREATE INDEX pgrn_index ON memos
USING pgroonga (content)
WITH (token_filters = '');
SET enable_seqscan = off;
SET enable_indexscan = on;
SET enable_bitmapscan = off;
SELECT id, content
FROM memos
WHERE content %% 'works';
id | content
----+-----------
1 | It works.
(1 row)

SELECT id, content
FROM memos
WHERE content %% 'work';
id | content
----+---------
2 | I work.
(1 row)

SELECT id, content
FROM memos
WHERE content %% 'worked';
id | content
----+-----------
3 | I worked.
(1 row)

DROP TABLE memos;
38 changes: 38 additions & 0 deletions expected/full-text-search/text/options/token-filters/none.out
@@ -0,0 +1,38 @@
CREATE TABLE memos (
id integer,
content text
);
INSERT INTO memos VALUES (1, 'It works.');
INSERT INTO memos VALUES (2, 'I work.');
INSERT INTO memos VALUES (3, 'I worked.');
CREATE INDEX pgrn_index ON memos
USING pgroonga (content)
WITH (token_filters = 'none');
SET enable_seqscan = off;
SET enable_indexscan = on;
SET enable_bitmapscan = off;
SELECT id, content
FROM memos
WHERE content %% 'works';
id | content
----+-----------
1 | It works.
(1 row)

SELECT id, content
FROM memos
WHERE content %% 'work';
id | content
----+---------
2 | I work.
(1 row)

SELECT id, content
FROM memos
WHERE content %% 'worked';
id | content
----+-----------
3 | I worked.
(1 row)

DROP TABLE memos;
12 changes: 12 additions & 0 deletions sql/full-text-search/text/options/plugins/one.sql
@@ -0,0 +1,12 @@
CREATE TABLE memos (
id integer,
content text
);

CREATE INDEX pgrn_index ON memos
USING pgroonga (content)
WITH (plugins = 'query_expanders/tsv');

SELECT pgroonga.command('object_exist QueryExpanderTSV')::json->>1;

DROP TABLE memos;
31 changes: 31 additions & 0 deletions sql/full-text-search/text/options/token-filters/custom.sql
@@ -0,0 +1,31 @@
CREATE TABLE memos (
id integer,
content text
);

INSERT INTO memos VALUES (1, 'It works.');
INSERT INTO memos VALUES (2, 'I work.');
INSERT INTO memos VALUES (3, 'I worked.');

CREATE INDEX pgrn_index ON memos
USING pgroonga (content)
WITH (plugins = 'token_filters/stem',
token_filters = 'TokenFilterStem');

SET enable_seqscan = off;
SET enable_indexscan = on;
SET enable_bitmapscan = off;

SELECT id, content
FROM memos
WHERE content %% 'works';

SELECT id, content
FROM memos
WHERE content %% 'work';

SELECT id, content
FROM memos
WHERE content %% 'worked';

DROP TABLE memos;
30 changes: 30 additions & 0 deletions sql/full-text-search/text/options/token-filters/empty.sql
@@ -0,0 +1,30 @@
CREATE TABLE memos (
id integer,
content text
);

INSERT INTO memos VALUES (1, 'It works.');
INSERT INTO memos VALUES (2, 'I work.');
INSERT INTO memos VALUES (3, 'I worked.');

CREATE INDEX pgrn_index ON memos
USING pgroonga (content)
WITH (token_filters = '');

SET enable_seqscan = off;
SET enable_indexscan = on;
SET enable_bitmapscan = off;

SELECT id, content
FROM memos
WHERE content %% 'works';

SELECT id, content
FROM memos
WHERE content %% 'work';

SELECT id, content
FROM memos
WHERE content %% 'worked';

DROP TABLE memos;
30 changes: 30 additions & 0 deletions sql/full-text-search/text/options/token-filters/none.sql
@@ -0,0 +1,30 @@
CREATE TABLE memos (
id integer,
content text
);

INSERT INTO memos VALUES (1, 'It works.');
INSERT INTO memos VALUES (2, 'I work.');
INSERT INTO memos VALUES (3, 'I worked.');

CREATE INDEX pgrn_index ON memos
USING pgroonga (content)
WITH (token_filters = 'none');

SET enable_seqscan = off;
SET enable_indexscan = on;
SET enable_bitmapscan = off;

SELECT id, content
FROM memos
WHERE content %% 'works';

SELECT id, content
FROM memos
WHERE content %% 'work';

SELECT id, content
FROM memos
WHERE content %% 'worked';

DROP TABLE memos;

0 comments on commit 5956237

Please sign in to comment.