Skip to content

Commit 7de75e1

Browse files
committed
Add rum_ts_score() - inverted to rum_ts_distance function.
Bump extension version, now 1.3.
1 parent 0f20de4 commit 7de75e1

10 files changed

+3438
-76
lines changed

Makefile

+5-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
MODULE_big = rum
44
EXTENSION = rum
5-
EXTVERSION = 1.2
5+
EXTVERSION = 1.3
66
PGFILEDESC = "RUM index access method"
77

88
OBJS = src/rumsort.o src/rum_ts_utils.o src/rumtsquery.o \
@@ -12,7 +12,9 @@ OBJS = src/rumsort.o src/rum_ts_utils.o src/rumtsquery.o \
1212
src/btree_rum.o src/rum_arr_utils.o $(WIN32RES)
1313

1414
DATA_first = rum--1.0.sql
15-
DATA_updates = rum--1.0--1.1.sql rum--1.1--1.2.sql
15+
DATA_updates = rum--1.0--1.1.sql rum--1.1--1.2.sql \
16+
rum--1.2--1.3.sql
17+
1618
DATA = $(DATA_first) rum--$(EXTVERSION).sql $(DATA_updates)
1719

1820
# Do not use DATA_built. It removes built files if clean target was used
@@ -52,7 +54,7 @@ wal-check: temp-install
5254

5355
all: $(SQL_built)
5456

55-
#9.6 requires 1.2 file but 10.0 could live with update files
57+
#9.6 requires 1.3 file but 10.0 could live with update files
5658
rum--$(EXTVERSION).sql: $(DATA_first) $(DATA_updates)
5759
cat $(DATA_first) $(DATA_updates) > rum--$(EXTVERSION).sql
5860

expected/rum.out

+35-26
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@ CREATE INDEX rumidx ON test_rum USING rum (a rum_tsvector_ops);
88
SELECT
99
a <=> to_tsquery('pg_catalog.english', 'way & (go | half)'),
1010
rum_ts_distance(a, to_tsquery('pg_catalog.english', 'way & (go | half)')),
11+
rum_ts_score(a, to_tsquery('pg_catalog.english', 'way & (go | half)')),
1112
*
1213
FROM test_rum
1314
ORDER BY a <=> to_tsquery('pg_catalog.english', 'way & (go | half)') limit 2;
14-
?column? | rum_ts_distance | t | a
15-
----------+-----------------+---+---
15+
?column? | rum_ts_distance | rum_ts_score | t | a
16+
----------+-----------------+--------------+---+---
1617
(0 rows)
1718

1819
-- Fill the table with data
@@ -131,26 +132,30 @@ SELECT count(*) FROM test_rum WHERE a @@ to_tsquery('pg_catalog.english',
131132
1
132133
(1 row)
133134

134-
SELECT rum_ts_distance(a, to_tsquery('pg_catalog.english', 'way')), *
135+
SELECT rum_ts_distance(a, to_tsquery('pg_catalog.english', 'way')),
136+
rum_ts_score(a, to_tsquery('pg_catalog.english', 'way')),
137+
*
135138
FROM test_rum
136139
WHERE a @@ to_tsquery('pg_catalog.english', 'way')
137140
ORDER BY a <=> to_tsquery('pg_catalog.english', 'way');
138-
rum_ts_distance | t | a
139-
-----------------+--------------------------------------------------------------------------+---------------------------------------------------------------
140-
16.4493 | my appreciation of you in a more complimentary way than by sending this | 'appreci':2 'complimentari':8 'send':12 'way':9
141-
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
142-
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
143-
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
141+
rum_ts_distance | rum_ts_score | t | a
142+
-----------------+--------------+--------------------------------------------------------------------------+---------------------------------------------------------------
143+
16.4493 | 0.0607927 | my appreciation of you in a more complimentary way than by sending this | 'appreci':2 'complimentari':8 'send':12 'way':9
144+
16.4493 | 0.0607927 | 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
145+
16.4493 | 0.0607927 | 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
146+
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
144147
(4 rows)
145148

146-
SELECT rum_ts_distance(a, to_tsquery('pg_catalog.english', 'way & (go | half)')), *
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)')),
151+
*
147152
FROM test_rum
148153
WHERE a @@ to_tsquery('pg_catalog.english', 'way & (go | half)')
149154
ORDER BY a <=> to_tsquery('pg_catalog.english', 'way & (go | half)');
150-
rum_ts_distance | t | a
151-
-----------------+---------------------------------------------------------------------+---------------------------------------------------------
152-
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
153-
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
155+
rum_ts_distance | rum_ts_score | t | a
156+
-----------------+--------------+---------------------------------------------------------------------+---------------------------------------------------------
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
154159
(2 rows)
155160

156161
SELECT
@@ -166,26 +171,30 @@ SELECT
166171
(2 rows)
167172

168173
-- Check ranking normalization
169-
SELECT rum_ts_distance(a, to_tsquery('pg_catalog.english', 'way'), 0), *
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),
176+
*
170177
FROM test_rum
171178
WHERE a @@ to_tsquery('pg_catalog.english', 'way')
172179
ORDER BY a <=> to_tsquery('pg_catalog.english', 'way');
173-
rum_ts_distance | t | a
174-
-----------------+--------------------------------------------------------------------------+---------------------------------------------------------------
175-
16.4493 | my appreciation of you in a more complimentary way than by sending this | 'appreci':2 'complimentari':8 'send':12 'way':9
176-
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
177-
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
178-
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
180+
rum_ts_distance | rum_ts_score | t | a
181+
-----------------+--------------+--------------------------------------------------------------------------+---------------------------------------------------------------
182+
16.4493 | 0.0607927 | my appreciation of you in a more complimentary way than by sending this | 'appreci':2 'complimentari':8 'send':12 'way':9
183+
16.4493 | 0.0607927 | 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
184+
16.4493 | 0.0607927 | 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
185+
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
179186
(4 rows)
180187

181-
SELECT rum_ts_distance(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),
189+
rum_ts_score(a, row(to_tsquery('pg_catalog.english', 'way & (go | half)'), 0)::rum_distance_query),
190+
*
182191
FROM test_rum
183192
WHERE a @@ to_tsquery('pg_catalog.english', 'way & (go | half)')
184193
ORDER BY a <=> to_tsquery('pg_catalog.english', 'way & (go | half)');
185-
rum_ts_distance | t | a
186-
-----------------+---------------------------------------------------------------------+---------------------------------------------------------
187-
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
188-
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
194+
rum_ts_distance | rum_ts_score | t | a
195+
-----------------+--------------+---------------------------------------------------------------------+---------------------------------------------------------
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
189198
(2 rows)
190199

191200
INSERT INTO test_rum (t) VALUES ('foo bar foo the over foo qq bar');

expected/rum_hash.out

+37-28
Original file line numberDiff line numberDiff line change
@@ -118,61 +118,70 @@ SELECT count(*) FROM test_rum_hash WHERE a @@ to_tsquery('pg_catalog.english',
118118
1
119119
(1 row)
120120

121-
SELECT rum_ts_distance(a, to_tsquery('pg_catalog.english', 'way')), *
121+
SELECT rum_ts_distance(a, to_tsquery('pg_catalog.english', 'way')),
122+
rum_ts_score(a, to_tsquery('pg_catalog.english', 'way')),
123+
*
122124
FROM test_rum_hash
123125
WHERE a @@ to_tsquery('pg_catalog.english', 'way')
124126
ORDER BY a <=> to_tsquery('pg_catalog.english', 'way');
125-
rum_ts_distance | t | a
126-
-----------------+--------------------------------------------------------------------------+---------------------------------------------------------------
127-
16.4493 | my appreciation of you in a more complimentary way than by sending this | 'appreci':2 'complimentari':8 'send':12 'way':9
128-
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
129-
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
130-
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
127+
rum_ts_distance | rum_ts_score | t | a
128+
-----------------+--------------+--------------------------------------------------------------------------+---------------------------------------------------------------
129+
16.4493 | 0.0607927 | my appreciation of you in a more complimentary way than by sending this | 'appreci':2 'complimentari':8 'send':12 'way':9
130+
16.4493 | 0.0607927 | 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
131+
16.4493 | 0.0607927 | 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
132+
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
131133
(4 rows)
132134

133-
SELECT rum_ts_distance(a, to_tsquery('pg_catalog.english', 'way & (go | half)')), *
135+
SELECT rum_ts_distance(a, to_tsquery('pg_catalog.english', 'way & (go | half)')),
136+
rum_ts_score(a, to_tsquery('pg_catalog.english', 'way & (go | half)')),
137+
*
134138
FROM test_rum_hash
135139
WHERE a @@ to_tsquery('pg_catalog.english', 'way & (go | half)')
136140
ORDER BY a <=> to_tsquery('pg_catalog.english', 'way & (go | half)');
137-
rum_ts_distance | t | a
138-
-----------------+---------------------------------------------------------------------+---------------------------------------------------------
139-
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
140-
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
141+
rum_ts_distance | rum_ts_score | t | a
142+
-----------------+--------------+---------------------------------------------------------------------+---------------------------------------------------------
143+
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
144+
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
141145
(2 rows)
142146

143147
SELECT
144148
a <=> to_tsquery('pg_catalog.english', 'way & (go | half)'),
145149
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)')),
146151
*
147152
FROM test_rum_hash
148153
ORDER BY a <=> to_tsquery('pg_catalog.english', 'way & (go | half)') limit 2;
149-
?column? | rum_ts_distance | t | a
150-
----------+-----------------+---------------------------------------------------------------------+---------------------------------------------------------
151-
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
152-
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
154+
?column? | rum_ts_distance | rum_ts_score | t | a
155+
----------+-----------------+--------------+---------------------------------------------------------------------+---------------------------------------------------------
156+
8.22467 | 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
157+
57.5727 | 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
153158
(2 rows)
154159

155160
-- Check ranking normalization
156-
SELECT rum_ts_distance(a, to_tsquery('pg_catalog.english', 'way'), 0), *
161+
SELECT rum_ts_distance(a, to_tsquery('pg_catalog.english', 'way'), 0),
162+
rum_ts_score(a, to_tsquery('pg_catalog.english', 'way'), 0),
163+
*
157164
FROM test_rum_hash
158165
WHERE a @@ to_tsquery('pg_catalog.english', 'way')
159166
ORDER BY a <=> to_tsquery('pg_catalog.english', 'way');
160-
rum_ts_distance | t | a
161-
-----------------+--------------------------------------------------------------------------+---------------------------------------------------------------
162-
16.4493 | my appreciation of you in a more complimentary way than by sending this | 'appreci':2 'complimentari':8 'send':12 'way':9
163-
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
164-
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
165-
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
167+
rum_ts_distance | rum_ts_score | t | a
168+
-----------------+--------------+--------------------------------------------------------------------------+---------------------------------------------------------------
169+
16.4493 | 0.0607927 | my appreciation of you in a more complimentary way than by sending this | 'appreci':2 'complimentari':8 'send':12 'way':9
170+
16.4493 | 0.0607927 | 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
171+
16.4493 | 0.0607927 | 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
172+
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
166173
(4 rows)
167174

168-
SELECT rum_ts_distance(a, row(to_tsquery('pg_catalog.english', 'way & (go | half)'), 0)::rum_distance_query), *
175+
SELECT rum_ts_distance(a, row(to_tsquery('pg_catalog.english', 'way & (go | half)'), 0)::rum_distance_query),
176+
rum_ts_score(a, row(to_tsquery('pg_catalog.english', 'way & (go | half)'), 0)::rum_distance_query),
177+
*
169178
FROM test_rum_hash
170179
WHERE a @@ to_tsquery('pg_catalog.english', 'way & (go | half)')
171180
ORDER BY a <=> to_tsquery('pg_catalog.english', 'way & (go | half)');
172-
rum_ts_distance | t | a
173-
-----------------+---------------------------------------------------------------------+---------------------------------------------------------
174-
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
175-
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
181+
rum_ts_distance | rum_ts_score | t | a
182+
-----------------+--------------+---------------------------------------------------------------------+---------------------------------------------------------
183+
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
184+
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
176185
(2 rows)
177186

178187
INSERT INTO test_rum_hash (t) VALUES ('foo bar foo the over foo qq bar');

0 commit comments

Comments
 (0)