You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
| tsvector >< tsquery | float4 | Returns distance between tsvector and tsquery.
38
+
39
+
## Examples
40
+
41
+
Let us assume we have the table:
42
+
43
+
```sql
44
+
CREATETABLEtest_rum(t text, a tsvector);
45
+
46
+
CREATETRIGGERtsvectorupdate
47
+
BEFORE UPDATEOR INSERT ON test_rum
48
+
FOR EACH ROW EXECUTE PROCEDURE tsvector_update_trigger('a', 'pg_catalog.english', 't');
49
+
50
+
INSERT INTO test_rum(t) VALUES ('The situation is most beautiful');
51
+
INSERT INTO test_rum(t) VALUES ('It is a beautiful');
52
+
INSERT INTO test_rum(t) VALUES ('It looks like a beautiful place');
53
+
```
54
+
55
+
To create the **rum** index we need create an extension:
56
+
57
+
```sql
58
+
CREATE EXTENSION rum;
59
+
```
60
+
61
+
Then we can create new index:
62
+
63
+
```sql
64
+
CREATEINDEXrumidxON test_rum USING rum (a rum_tsvector_ops);
65
+
```
66
+
67
+
And we can execute the following queries:
68
+
69
+
```sql
70
+
=# SELECT t, a >< to_tsquery('english', 'beautiful | place') AS rank FROM test_rum WHERE a @@ to_tsquery('english', 'beautiful | place') order by a >< to_tsquery('english', 'beautiful | place');
71
+
t | rank
72
+
---------------------------------+-----------
73
+
The situation is most beautiful | 0.0303964
74
+
It is a beautiful | 0.0303964
75
+
It looks like a beautiful place | 0.0607927
76
+
(3 rows)
77
+
78
+
=# SELECT t, a >< to_tsquery('english', 'place | situation') AS rank FROM test_rum WHERE a @@ to_tsquery('english', 'place | situation') order by a >< to_tsquery('english', 'place | situation');
79
+
t | rank
80
+
---------------------------------+-----------
81
+
The situation is most beautiful | 0.0303964
82
+
It looks like a beautiful place | 0.0303964
83
+
(2 rows)
84
+
```
85
+
13
86
## Authors
14
87
15
88
Alexander Korotkov <a.korotkov@postgrespro.ru> Postgres Professional Ltd., Russia
0 commit comments