|
| 1 | +create schema v; |
| 2 | +create table v.roon( |
| 3 | + id serial primary key, |
| 4 | + content text |
| 5 | +); |
| 6 | +with tokenizers as ( |
| 7 | + select |
| 8 | + x |
| 9 | + from |
| 10 | + jsonb_array_elements( |
| 11 | + (select pgroonga_command('tokenizer_list'))::jsonb |
| 12 | + ) x(val) |
| 13 | + limit |
| 14 | + 1 |
| 15 | + offset |
| 16 | + 1 -- first record is unrelated and not stable |
| 17 | +) |
| 18 | +select |
| 19 | + t.x::jsonb ->> 'name' |
| 20 | +from |
| 21 | + jsonb_array_elements((select * from tokenizers)) t(x) |
| 22 | +order by |
| 23 | + t.x::jsonb ->> 'name'; |
| 24 | + ?column? |
| 25 | +--------------------------------------------- |
| 26 | + TokenBigram |
| 27 | + TokenBigramIgnoreBlank |
| 28 | + TokenBigramIgnoreBlankSplitSymbol |
| 29 | + TokenBigramIgnoreBlankSplitSymbolAlpha |
| 30 | + TokenBigramIgnoreBlankSplitSymbolAlphaDigit |
| 31 | + TokenBigramSplitSymbol |
| 32 | + TokenBigramSplitSymbolAlpha |
| 33 | + TokenBigramSplitSymbolAlphaDigit |
| 34 | + TokenDelimit |
| 35 | + TokenDelimitNull |
| 36 | + TokenDocumentVectorBM25 |
| 37 | + TokenDocumentVectorTFIDF |
| 38 | + TokenMecab |
| 39 | + TokenNgram |
| 40 | + TokenPattern |
| 41 | + TokenRegexp |
| 42 | + TokenTable |
| 43 | + TokenTrigram |
| 44 | + TokenUnigram |
| 45 | +(19 rows) |
| 46 | + |
| 47 | +insert into v.roon (content) |
| 48 | +values |
| 49 | + ('Hello World'), |
| 50 | + ('PostgreSQL with PGroonga is a thing'), |
| 51 | + ('This is a full-text search test'), |
| 52 | + ('PGroonga supports various languages'); |
| 53 | +-- Create default index |
| 54 | +create index pgroonga_index on v.roon using pgroonga (content); |
| 55 | +-- Create mecab tokenizer index since we had a bug with this one once |
| 56 | +create index pgroonga_index_mecab on v.roon using pgroonga (content) with (tokenizer='TokenMecab'); |
| 57 | +-- Run some queries to test the index |
| 58 | +select * from v.roon where content &@~ 'Hello'; |
| 59 | + id | content |
| 60 | +----+------------- |
| 61 | + 1 | Hello World |
| 62 | +(1 row) |
| 63 | + |
| 64 | +select * from v.roon where content &@~ 'powerful'; |
| 65 | + id | content |
| 66 | +----+--------- |
| 67 | +(0 rows) |
| 68 | + |
| 69 | +select * from v.roon where content &@~ 'supports'; |
| 70 | + id | content |
| 71 | +----+------------------------------------- |
| 72 | + 4 | PGroonga supports various languages |
| 73 | +(1 row) |
| 74 | + |
| 75 | +drop schema v cascade; |
| 76 | +NOTICE: drop cascades to table v.roon |
0 commit comments