|
| 1 | +CREATE EXTENSION hunspell_en_us; |
| 2 | +CREATE TABLE table1(name varchar); |
| 3 | +INSERT INTO table1 VALUES ('leaves'), ('leaved'), ('leaving'), |
| 4 | +('inability'), ('abilities'), ('disability'), ('ability'); |
| 5 | +SELECT d.* FROM table1 AS t, LATERAL ts_debug('public.english', t.name) AS d; |
| 6 | + alias | description | token | dictionaries | dictionary | lexemes |
| 7 | +-----------+-----------------+------------+---------------------------------+------------------+----------- |
| 8 | + asciiword | Word, all ASCII | leaves | {english_hunspell,english_stem} | english_hunspell | {leave} |
| 9 | + asciiword | Word, all ASCII | leaved | {english_hunspell,english_stem} | english_hunspell | {leave} |
| 10 | + asciiword | Word, all ASCII | leaving | {english_hunspell,english_stem} | english_hunspell | {leave} |
| 11 | + asciiword | Word, all ASCII | inability | {english_hunspell,english_stem} | english_hunspell | {ability} |
| 12 | + asciiword | Word, all ASCII | abilities | {english_hunspell,english_stem} | english_hunspell | {ability} |
| 13 | + asciiword | Word, all ASCII | disability | {english_hunspell,english_stem} | english_hunspell | {ability} |
| 14 | + asciiword | Word, all ASCII | ability | {english_hunspell,english_stem} | english_hunspell | {ability} |
| 15 | +(7 rows) |
| 16 | + |
| 17 | +CREATE INDEX name_idx ON table1 USING GIN (to_tsvector('public.english', "name")); |
| 18 | +SELECT * FROM table1 WHERE to_tsvector('public.english', name) |
| 19 | +@@ to_tsquery('public.english', 'leaving'); |
| 20 | + name |
| 21 | +--------- |
| 22 | + leaves |
| 23 | + leaved |
| 24 | + leaving |
| 25 | +(3 rows) |
| 26 | + |
| 27 | +SELECT * FROM table1 WHERE to_tsvector('public.english', name) |
| 28 | +@@ to_tsquery('public.english', 'abilities'); |
| 29 | + name |
| 30 | +------------ |
| 31 | + inability |
| 32 | + abilities |
| 33 | + disability |
| 34 | + ability |
| 35 | +(4 rows) |
| 36 | + |
| 37 | +SELECT * FROM table1 WHERE to_tsvector('public.english', name) |
| 38 | +@@ to_tsquery('public.english', 'ability'); |
| 39 | + name |
| 40 | +------------ |
| 41 | + inability |
| 42 | + abilities |
| 43 | + disability |
| 44 | + ability |
| 45 | +(4 rows) |
| 46 | + |
| 47 | +DROP INDEX name_idx; |
| 48 | +CREATE INDEX name_idx ON table1 USING GIST (to_tsvector('public.english', "name")); |
| 49 | +SELECT * FROM table1 WHERE to_tsvector('public.english', name) |
| 50 | +@@ to_tsquery('public.english', 'leaving'); |
| 51 | + name |
| 52 | +--------- |
| 53 | + leaves |
| 54 | + leaved |
| 55 | + leaving |
| 56 | +(3 rows) |
| 57 | + |
| 58 | +SELECT * FROM table1 WHERE to_tsvector('public.english', name) |
| 59 | +@@ to_tsquery('public.english', 'abilities'); |
| 60 | + name |
| 61 | +------------ |
| 62 | + inability |
| 63 | + abilities |
| 64 | + disability |
| 65 | + ability |
| 66 | +(4 rows) |
| 67 | + |
| 68 | +SELECT * FROM table1 WHERE to_tsvector('public.english', name) |
| 69 | +@@ to_tsquery('public.english', 'ability'); |
| 70 | + name |
| 71 | +------------ |
| 72 | + inability |
| 73 | + abilities |
| 74 | + disability |
| 75 | + ability |
| 76 | +(4 rows) |
| 77 | + |