|
1 | 1 | CREATE EXTENSION hunspell_en_us; |
2 | | -SELECT ts_lexize('english_hunspell', 'stories'); |
3 | | - ts_lexize |
4 | | ------------ |
5 | | - {story} |
6 | | -(1 row) |
| 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) |
7 | 16 |
|
8 | | -SELECT ts_lexize('english_hunspell', 'traveled'); |
9 | | - ts_lexize |
10 | | -------------------- |
11 | | - {traveled,travel} |
12 | | -(1 row) |
| 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) |
13 | 26 |
|
14 | | -SELECT ts_lexize('english_hunspell', 'eaten'); |
15 | | - ts_lexize |
16 | | -------------- |
17 | | - {eaten,eat} |
18 | | -(1 row) |
19 | | - |
20 | | -SELECT ts_lexize('english_hunspell', 'I''m'); |
21 | | - ts_lexize |
22 | | ------------ |
23 | | - {i'm} |
24 | | -(1 row) |
25 | | - |
26 | | -SELECT ts_lexize('english_hunspell', 'Saturdays'); |
27 | | - ts_lexize |
| 27 | +SELECT * FROM table1 WHERE to_tsvector('public.english', name) |
| 28 | +@@ to_tsquery('public.english', 'abilities'); |
| 29 | + name |
28 | 30 | ------------ |
29 | | - {saturday} |
30 | | -(1 row) |
31 | | - |
32 | | -SELECT ts_lexize('english_hunspell', 'healthcare'); |
33 | | - ts_lexize |
34 | | --------------- |
35 | | - {healthcare} |
36 | | -(1 row) |
| 31 | + inability |
| 32 | + abilities |
| 33 | + disability |
| 34 | + ability |
| 35 | +(4 rows) |
37 | 36 |
|
38 | | -SELECT ts_lexize('english_hunspell', 'generally'); |
39 | | - ts_lexize |
40 | | ------------ |
41 | | - {general} |
42 | | -(1 row) |
| 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) |
43 | 46 |
|
44 | | -SELECT ts_lexize('english_hunspell', 'integrating'); |
45 | | - ts_lexize |
46 | | -------------- |
47 | | - {integrate} |
48 | | -(1 row) |
| 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) |
49 | 57 |
|
50 | | -SELECT ts_lexize('english_hunspell', 'lankiness''s'); |
51 | | - ts_lexize |
52 | | -------------- |
53 | | - {lankiness} |
54 | | -(1 row) |
| 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) |
55 | 67 |
|
56 | | -SELECT ts_lexize('english_hunspell', 'rewritten'); |
57 | | - ts_lexize |
58 | | ------------ |
59 | | - {written} |
60 | | -(1 row) |
| 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) |
61 | 77 |
|