@@ -132,8 +132,8 @@ SELECT count(*) FROM test_rum WHERE a @@ to_tsquery('pg_catalog.english',
132132 1
133133(1 row)
134134
135- SELECT rum_ts_distance(a, to_tsquery('pg_catalog.english', 'way')),
136- rum_ts_score(a, to_tsquery('pg_catalog.english', 'way')),
135+ SELECT rum_ts_distance(a, to_tsquery('pg_catalog.english', 'way'))::numeric(10,4),
136+ rum_ts_score(a, to_tsquery('pg_catalog.english', 'way'))::numeric(10,7) ,
137137 *
138138 FROM test_rum
139139 WHERE a @@ to_tsquery('pg_catalog.english', 'way')
@@ -146,33 +146,33 @@ SELECT rum_ts_distance(a, to_tsquery('pg_catalog.english', 'way')),
146146 16.4493 | 0.0607927 | 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
147147(4 rows)
148148
149- SELECT rum_ts_distance(a, to_tsquery('pg_catalog.english', 'way & (go | half)')),
150- rum_ts_score(a, to_tsquery('pg_catalog.english', 'way & (go | half)')),
149+ SELECT rum_ts_distance(a, to_tsquery('pg_catalog.english', 'way & (go | half)'))::numeric(10,4) ,
150+ rum_ts_score(a, to_tsquery('pg_catalog.english', 'way & (go | half)'))::numeric(10,6) ,
151151 *
152152 FROM test_rum
153153 WHERE a @@ to_tsquery('pg_catalog.english', 'way & (go | half)')
154154 ORDER BY a <=> to_tsquery('pg_catalog.english', 'way & (go | half)');
155155 rum_ts_distance | rum_ts_score | t | a
156156-----------------+--------------+---------------------------------------------------------------------+---------------------------------------------------------
157- 8.22467 | 0.121585 | 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
158- 57.5727 | 0.0173693 | 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
157+ 8.2247 | 0.121585 | 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
158+ 57.5727 | 0.017369 | 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
159159(2 rows)
160160
161161SELECT
162- a <=> to_tsquery('pg_catalog.english', 'way & (go | half)'),
163- rum_ts_distance(a, to_tsquery('pg_catalog.english', 'way & (go | half)')),
162+ ( a <=> to_tsquery('pg_catalog.english', 'way & (go | half)'))::numeric(10,4) AS distance,
163+ rum_ts_distance(a, to_tsquery('pg_catalog.english', 'way & (go | half)'))::numeric(10,4) ,
164164 *
165165 FROM test_rum
166166 ORDER BY a <=> to_tsquery('pg_catalog.english', 'way & (go | half)') limit 2;
167- ?column? | rum_ts_distance | t | a
167+ distance | rum_ts_distance | t | a
168168----------+-----------------+---------------------------------------------------------------------+---------------------------------------------------------
169- 8.22467 | 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
169+ 8.2247 | 8.2247 | 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
170170 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
171171(2 rows)
172172
173173-- Check ranking normalization
174- SELECT rum_ts_distance(a, to_tsquery('pg_catalog.english', 'way'), 0),
175- rum_ts_score(a, to_tsquery('pg_catalog.english', 'way'), 0),
174+ SELECT rum_ts_distance(a, to_tsquery('pg_catalog.english', 'way'), 0)::numeric(10,4) ,
175+ rum_ts_score(a, to_tsquery('pg_catalog.english', 'way'), 0)::numeric(10,7) ,
176176 *
177177 FROM test_rum
178178 WHERE a @@ to_tsquery('pg_catalog.english', 'way')
@@ -185,16 +185,16 @@ SELECT rum_ts_distance(a, to_tsquery('pg_catalog.english', 'way'), 0),
185185 16.4493 | 0.0607927 | 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
186186(4 rows)
187187
188- SELECT rum_ts_distance(a, row(to_tsquery('pg_catalog.english', 'way & (go | half)'), 0)::rum_distance_query),
189- rum_ts_score(a, row(to_tsquery('pg_catalog.english', 'way & (go | half)'), 0)::rum_distance_query),
188+ SELECT rum_ts_distance(a, row(to_tsquery('pg_catalog.english', 'way & (go | half)'), 0)::rum_distance_query)::numeric(10,4) ,
189+ rum_ts_score(a, row(to_tsquery('pg_catalog.english', 'way & (go | half)'), 0)::rum_distance_query)::numeric(10,6) ,
190190 *
191191 FROM test_rum
192192 WHERE a @@ to_tsquery('pg_catalog.english', 'way & (go | half)')
193193 ORDER BY a <=> to_tsquery('pg_catalog.english', 'way & (go | half)');
194194 rum_ts_distance | rum_ts_score | t | a
195195-----------------+--------------+---------------------------------------------------------------------+---------------------------------------------------------
196- 8.22467 | 0.121585 | 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
197- 57.5727 | 0.0173693 | 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
196+ 8.2247 | 0.121585 | 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
197+ 57.5727 | 0.017369 | 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
198198(2 rows)
199199
200200INSERT INTO test_rum (t) VALUES ('foo bar foo the over foo qq bar');
@@ -232,65 +232,71 @@ SELECT a FROM test_rum WHERE a @@ to_tsquery('pg_catalog.english', 'bar') ORDER
232232(1 row)
233233
234234-- Check full-index scan with order by
235- SELECT a <=> to_tsquery('pg_catalog.english', 'ever|wrote') FROM test_rum ORDER BY a <=> to_tsquery('pg_catalog.english', 'ever|wrote');
236- ?column?
235+ SELECT
236+ CASE WHEN distance = 'Infinity' THEN -1
237+ ELSE distance::numeric(10,4)
238+ END distance
239+ FROM
240+ (SELECT a <=> to_tsquery('pg_catalog.english', 'ever|wrote') AS distance
241+ FROM test_rum ORDER BY a <=> to_tsquery('pg_catalog.english', 'ever|wrote')) t;
242+ distance
237243----------
238244 16.4493
239245 16.4493
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- Infinity
271- Infinity
272- Infinity
273- Infinity
274- Infinity
275- Infinity
276- Infinity
277- Infinity
278- Infinity
279- Infinity
280- Infinity
281- Infinity
282- Infinity
283- Infinity
284- Infinity
285- Infinity
286- Infinity
287- Infinity
288- Infinity
289- Infinity
290- Infinity
291- Infinity
292- Infinity
293- Infinity
246+ -1
247+ -1
248+ -1
249+ -1
250+ -1
251+ -1
252+ -1
253+ -1
254+ -1
255+ -1
256+ -1
257+ -1
258+ -1
259+ -1
260+ -1
261+ -1
262+ -1
263+ -1
264+ -1
265+ -1
266+ -1
267+ -1
268+ -1
269+ -1
270+ -1
271+ -1
272+ -1
273+ -1
274+ -1
275+ -1
276+ -1
277+ -1
278+ -1
279+ -1
280+ -1
281+ -1
282+ -1
283+ -1
284+ -1
285+ -1
286+ -1
287+ -1
288+ -1
289+ -1
290+ -1
291+ -1
292+ -1
293+ -1
294+ -1
295+ -1
296+ -1
297+ -1
298+ -1
299+ -1
294300(56 rows)
295301
296302CREATE TABLE tst (i int4, t tsvector);
@@ -325,15 +331,15 @@ SELECT a <=> to_tsquery('pg_catalog.english', 'w:*'), *
325331 Order By: (a <=> '''w'':*'::tsquery)
326332(3 rows)
327333
328- SELECT a <=> to_tsquery('pg_catalog.english', 'w:*'), *
334+ SELECT ( a <=> to_tsquery('pg_catalog.english', 'w:*'))::numeric(10,4) AS distance , *
329335 FROM test_rum
330336 WHERE a @@ to_tsquery('pg_catalog.english', 'w:*')
331337 ORDER BY a <=> to_tsquery('pg_catalog.english', 'w:*');
332- ?column? | t | a
338+ distance | t | a
333339----------+--------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------
334- 8.22467 | 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
335- 8.22467 | wine, but wouldn't you divide with your neighbors! The columns in the | 'column':11 'divid':6 'neighbor':9 'wine':1 'wouldn':3
336- 8.22467 | not say, but you wrote as if you knew it by sight as well as by heart. | 'heart':17 'knew':9 'say':2 'sight':12 'well':14 'wrote':5
340+ 8.2247 | 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
341+ 8.2247 | wine, but wouldn't you divide with your neighbors! The columns in the | 'column':11 'divid':6 'neighbor':9 'wine':1 'wouldn':3
342+ 8.2247 | not say, but you wrote as if you knew it by sight as well as by heart. | 'heart':17 'knew':9 'say':2 'sight':12 'well':14 'wrote':5
337343 16.4493 | little series of pictures. Have you ever been here, I wonder? You did | 'ever':7 'littl':1 'pictur':4 'seri':2 'wonder':11
338344 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
339345 16.4493 | _berg_, "the Jettenhuhl, a wooded spur of the Konigestuhl." Look at it | 'berg':1 'jettenhuhl':3 'konigestuhl':9 'look':10 'spur':6 'wood':5
@@ -347,16 +353,16 @@ SELECT a <=> to_tsquery('pg_catalog.english', 'w:*'), *
347353 16.4493 | my appreciation of you in a more complimentary way than by sending this | 'appreci':2 'complimentari':8 'send':12 'way':9
348354(14 rows)
349355
350- SELECT a <=> to_tsquery('pg_catalog.english', 'b:*'), *
356+ SELECT ( a <=> to_tsquery('pg_catalog.english', 'b:*'))::numeric(10,4) AS distance , *
351357 FROM test_rum
352358 WHERE a @@ to_tsquery('pg_catalog.english', 'b:*')
353359 ORDER BY a <=> to_tsquery('pg_catalog.english', 'b:*');
354- ?column? | t | a
360+ distance | t | a
355361----------+--------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------
356- 8.22467 | been trying my best to get all those "passes" into my brain. Now, thanks | 'best':4 'brain':12 'get':6 'pass':9 'thank':14 'tri':2
357- 8.22467 | All the above information, I beg you to believe, I do not intend you | 'beg':6 'believ':9 'inform':4 'intend':13
358- 8.22467 | curious spectacle, but on the whole had "the banquet-hall deserted" | 'banquet':10 'banquet-hal':9 'curious':1 'desert':12 'hall':11 'spectacl':2 'whole':6
359- 8.22467 | oaks, limes and maples, bordered with flower-beds and shrubberies, and | 'bed':9 'border':5 'flower':8 'flower-b':7 'lime':2 'mapl':4 'oak':1 'shrubberi':11
362+ 8.2247 | been trying my best to get all those "passes" into my brain. Now, thanks | 'best':4 'brain':12 'get':6 'pass':9 'thank':14 'tri':2
363+ 8.2247 | All the above information, I beg you to believe, I do not intend you | 'beg':6 'believ':9 'inform':4 'intend':13
364+ 8.2247 | curious spectacle, but on the whole had "the banquet-hall deserted" | 'banquet':10 'banquet-hal':9 'curious':1 'desert':12 'hall':11 'spectacl':2 'whole':6
365+ 8.2247 | oaks, limes and maples, bordered with flower-beds and shrubberies, and | 'bed':9 'border':5 'flower':8 'flower-b':7 'lime':2 'mapl':4 'oak':1 'shrubberi':11
360366 13.1595 | foo bar foo the over foo qq bar | 'bar':2,8 'foo':1,3,6 'qq':7
361367 16.4493 | ornamental building, and I wish you could see it, if you have not seen | 'build':2 'could':7 'ornament':1 'see':8 'seen':14 'wish':5
362368 16.4493 | the--nearest guide-book! | 'book':5 'guid':4 'guide-book':3 'nearest':2
@@ -375,14 +381,14 @@ SELECT a <=> to_tsquery('pg_catalog.english', 'b:*'), *
375381 16.4493 | the few that escaped destruction in 1693. It is a beautiful, highly | '1693':7 'beauti':11 'destruct':5 'escap':4 'high':12
376382(20 rows)
377383
378- select 'bjarn:6237 stroustrup:6238'::tsvector <=> 'bjarn <-> stroustrup'::tsquery;
379- ?column?
384+ select ( 'bjarn:6237 stroustrup:6238'::tsvector <=> 'bjarn <-> stroustrup'::tsquery)::numeric(10,5) AS distance ;
385+ distance
380386----------
381387 8.22467
382388(1 row)
383389
384- SELECT 'stroustrup:5508B,6233B,6238B bjarn:6235B,6237B' <=> 'bjarn <-> stroustrup'::tsquery;
385- ?column?
390+ SELECT ( 'stroustrup:5508B,6233B,6238B bjarn:6235B,6237B' <=> 'bjarn <-> stroustrup'::tsquery)::numeric(10,5) AS distance ;
391+ distance
386392----------
387393 2.05617
388394(1 row)
0 commit comments