Skip to content

Commit ac9e20a

Browse files
committed
Fix the README
1 parent effc1b8 commit ac9e20a

File tree

1 file changed

+73
-0
lines changed

1 file changed

+73
-0
lines changed

README.md

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,79 @@ on the GIN access methods code.
1010
This module available under the same license as
1111
[PostgreSQL](http://www.postgresql.org/about/licence/).
1212

13+
## Installation
14+
15+
Before build and install **rum** you should ensure following:
16+
17+
* PostgreSQL version is 9.6.
18+
19+
Typical installation procedure may look like this:
20+
21+
$ git clone https://github.com/postgrespro/rum
22+
$ cd rum
23+
$ make USE_PGXS=1
24+
$ sudo make USE_PGXS=1 install
25+
$ make USE_PGXS=1 installcheck
26+
$ psql DB -c "CREATE EXTENSION rum;"
27+
28+
## New access method and operator class
29+
30+
The **rum** module provides the access method **rum** and the operator class
31+
**rum_tsvector_ops**.
32+
33+
The module provides new operators.
34+
35+
| Operator | Returns | Description
36+
| ------------------- | ------- | ----------------------------------------------
37+
| 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+
CREATE TABLE test_rum(t text, a tsvector);
45+
46+
CREATE TRIGGER tsvectorupdate
47+
BEFORE UPDATE OR 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+
CREATE INDEX rumidx ON 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+
1386
## Authors
1487

1588
Alexander Korotkov <a.korotkov@postgrespro.ru> Postgres Professional Ltd., Russia

0 commit comments

Comments
 (0)