@@ -5,6 +5,8 @@ BEFORE UPDATE OR INSERT ON test_rum
55FOR EACH ROW EXECUTE PROCEDURE tsvector_update_trigger('a', 'pg_catalog.english', 't');
66CREATE INDEX rumidx ON test_rum USING rum (a rum_tsvector_ops);
77\copy test_rum(t) from 'data/rum.data';
8+ CREATE INDEX failed_rumidx ON test_rum USING rum (a rum_tsvector_timestamp_ops);
9+ ERROR: additional information attribute "a" is not found in index
810SET enable_seqscan=off;
911explain (costs off)
1012SELECT count(*) FROM test_rum WHERE a @@ to_tsquery('pg_catalog.english', 'ever|wrote');
@@ -76,6 +78,30 @@ SELECT count(*) FROM test_rum WHERE a @@ to_tsquery('pg_catalog.english', '(comp
7678 2
7779(1 row)
7880
81+ SELECT count(*) FROM test_rum WHERE a @@ to_tsquery('pg_catalog.english', '(gave | half) <-> way');
82+ count
83+ -------
84+ 2
85+ (1 row)
86+
87+ SELECT count(*) FROM test_rum WHERE a @@ to_tsquery('pg_catalog.english', '(gave | !half) <-> way');
88+ count
89+ -------
90+ 3
91+ (1 row)
92+
93+ SELECT count(*) FROM test_rum WHERE a @@ to_tsquery('pg_catalog.english', '!gave & way');
94+ count
95+ -------
96+ 3
97+ (1 row)
98+
99+ SELECT count(*) FROM test_rum WHERE a @@ to_tsquery('pg_catalog.english', '!gave & wooded & !look');
100+ count
101+ -------
102+ 1
103+ (1 row)
104+
79105SELECT count(*) FROM test_rum WHERE a @@ to_tsquery('pg_catalog.english',
80106'def <-> fgr');
81107 count
@@ -124,6 +150,29 @@ SELECT
124150 57.5727 | 57.5727 | thinking--“to go or not to go?” We are this far on the way. Reached | 'far':11 'go':3,7 'reach':15 'think':1 'way':14
125151(2 rows)
126152
153+ -- Check ranking normalization
154+ SELECT rum_ts_distance(a, to_tsquery('pg_catalog.english', 'way'), 0), *
155+ FROM test_rum
156+ WHERE a @@ to_tsquery('pg_catalog.english', 'way')
157+ ORDER BY a <=> to_tsquery('pg_catalog.english', 'way');
158+ rum_ts_distance | t | a
159+ -----------------+--------------------------------------------------------------------------+---------------------------------------------------------------
160+ 16.4493 | my appreciation of you in a more complimentary way than by sending this | 'appreci':2 'complimentari':8 'send':12 'way':9
161+ 16.4493 | itself. Put on your “specs” and look at the castle, half way up the | 'castl':10 'half':11 'look':7 'put':2 'spec':5 'way':12
162+ 16.4493 | so well that only a fragment, as it were, gave way. It still hangs as if | 'fragment':6 'gave':10 'hang':14 'still':13 'way':11 'well':2
163+ 16.4493 | thinking--“to go or not to go?” We are this far on the way. Reached | 'far':11 'go':3,7 'reach':15 'think':1 'way':14
164+ (4 rows)
165+
166+ SELECT rum_ts_distance(a, row(to_tsquery('pg_catalog.english', 'way & (go | half)'), 0)::rum_distance_query), *
167+ FROM test_rum
168+ WHERE a @@ to_tsquery('pg_catalog.english', 'way & (go | half)')
169+ ORDER BY a <=> to_tsquery('pg_catalog.english', 'way & (go | half)');
170+ rum_ts_distance | t | a
171+ -----------------+---------------------------------------------------------------------+---------------------------------------------------------
172+ 8.22467 | itself. Put on your “specs” and look at the castle, half way up the | 'castl':10 'half':11 'look':7 'put':2 'spec':5 'way':12
173+ 57.5727 | thinking--“to go or not to go?” We are this far on the way. Reached | 'far':11 'go':3,7 'reach':15 'think':1 'way':14
174+ (2 rows)
175+
127176INSERT INTO test_rum (t) VALUES ('foo bar foo the over foo qq bar');
128177INSERT INTO test_rum (t) VALUES ('345 qwerty copyright');
129178INSERT INTO test_rum (t) VALUES ('345 qwerty');
@@ -158,6 +207,68 @@ SELECT a FROM test_rum WHERE a @@ to_tsquery('pg_catalog.english', 'bar') ORDER
158207 'bar':2,8 'foo':1,3,6 'qq':7
159208(1 row)
160209
210+ -- Check full-index scan with order by
211+ SELECT a <=> to_tsquery('pg_catalog.english', 'ever|wrote') FROM test_rum ORDER BY a <=> to_tsquery('pg_catalog.english', 'ever|wrote');
212+ ?column?
213+ ----------
214+ 16.4493
215+ 16.4493
216+ Infinity
217+ Infinity
218+ Infinity
219+ Infinity
220+ Infinity
221+ Infinity
222+ Infinity
223+ Infinity
224+ Infinity
225+ Infinity
226+ Infinity
227+ Infinity
228+ Infinity
229+ Infinity
230+ Infinity
231+ Infinity
232+ Infinity
233+ Infinity
234+ Infinity
235+ Infinity
236+ Infinity
237+ Infinity
238+ Infinity
239+ Infinity
240+ Infinity
241+ Infinity
242+ Infinity
243+ Infinity
244+ Infinity
245+ Infinity
246+ Infinity
247+ Infinity
248+ Infinity
249+ Infinity
250+ Infinity
251+ Infinity
252+ Infinity
253+ Infinity
254+ Infinity
255+ Infinity
256+ Infinity
257+ Infinity
258+ Infinity
259+ Infinity
260+ Infinity
261+ Infinity
262+ Infinity
263+ Infinity
264+ Infinity
265+ Infinity
266+ Infinity
267+ Infinity
268+ Infinity
269+ Infinity
270+ (56 rows)
271+
161272CREATE TABLE tst (i int4, t tsvector);
162273INSERT INTO tst SELECT i%10, to_tsvector('simple', substr(md5(i::text), 1, 1)) FROM generate_series(1,100000) i;
163274CREATE INDEX tstidx ON tst USING rum (t rum_tsvector_ops);