|
| 1 | +<!-- doc/src/sgml/rum.sgml --> |
| 2 | + |
| 3 | +<sect1 id="rum"> |
| 4 | + <title>RUM - RUM access method</title> |
| 5 | + <sect2 id="run-introduction"> |
| 6 | + <title>Introduction</title> |
| 7 | + <para> |
| 8 | + The <emphasis role="strong">rum</emphasis> module provides access |
| 9 | + method to work with RUM index. It is based on the GIN access |
| 10 | + methods code. |
| 11 | + </para> |
| 12 | + </sect2> |
| 13 | + <sect2 id="rum-license"> |
| 14 | + <title>License</title> |
| 15 | + <para> |
| 16 | + This module available under the same license as |
| 17 | + <ulink url="http://www.postgresql.org/about/licence/">PostgreSQL</ulink>. |
| 18 | + </para> |
| 19 | + </sect2> |
| 20 | + <sect2 id="rum-new-access-method-and-operator-class"> |
| 21 | + <title>New access method and operator class</title> |
| 22 | + <para> |
| 23 | + The <emphasis role="strong">rum</emphasis> module provides the |
| 24 | + access method <emphasis role="strong">rum</emphasis> and the |
| 25 | + operator class |
| 26 | + <emphasis role="strong">rum_tsvector_ops</emphasis>. |
| 27 | + </para> |
| 28 | + <para> |
| 29 | + The module provides new operators. |
| 30 | + </para> |
| 31 | + <informaltable> |
| 32 | + <tgroup cols="3"> |
| 33 | + <colspec align="left" > |
| 34 | + <colspec align="left" > |
| 35 | + <colspec align="left" > |
| 36 | + <thead> |
| 37 | + <row> |
| 38 | + <entry> |
| 39 | + Operator |
| 40 | + </entry> |
| 41 | + <entry> |
| 42 | + Returns |
| 43 | + </entry> |
| 44 | + <entry> |
| 45 | + Description |
| 46 | + </entry> |
| 47 | + </row> |
| 48 | + </thead> |
| 49 | + <tbody> |
| 50 | + <row> |
| 51 | + <entry> |
| 52 | + tsvector <=> tsquery |
| 53 | + </entry> |
| 54 | + <entry> |
| 55 | + float4 |
| 56 | + </entry> |
| 57 | + <entry> |
| 58 | + Returns distance between tsvector and tsquery. |
| 59 | + </entry> |
| 60 | + </row> |
| 61 | + </tbody> |
| 62 | + </tgroup> |
| 63 | + </informaltable> |
| 64 | + </sect2> |
| 65 | + <sect2 id="rum-examples"> |
| 66 | + <title>Examples</title> |
| 67 | + <para> |
| 68 | + Let us assume we have the table: |
| 69 | + </para> |
| 70 | + <programlisting> |
| 71 | +CREATE TABLE test_rum(t text, a tsvector); |
| 72 | + |
| 73 | +CREATE TRIGGER tsvectorupdate |
| 74 | +BEFORE UPDATE OR INSERT ON test_rum |
| 75 | +FOR EACH ROW EXECUTE PROCEDURE tsvector_update_trigger('a', 'pg_catalog.english', 't'); |
| 76 | + |
| 77 | +INSERT INTO test_rum(t) VALUES ('The situation is most beautiful'); |
| 78 | +INSERT INTO test_rum(t) VALUES ('It is a beautiful'); |
| 79 | +INSERT INTO test_rum(t) VALUES ('It looks like a beautiful place'); |
| 80 | +</programlisting> |
| 81 | + <para> |
| 82 | + To create the <emphasis role="strong">rum</emphasis> index we need |
| 83 | + create an extension: |
| 84 | + </para> |
| 85 | + <programlisting> |
| 86 | +CREATE EXTENSION rum; |
| 87 | +</programlisting> |
| 88 | + <para> |
| 89 | + Then we can create new index: |
| 90 | + </para> |
| 91 | + <programlisting> |
| 92 | +CREATE INDEX rumidx ON test_rum USING rum (a rum_tsvector_ops); |
| 93 | +</programlisting> |
| 94 | + <para> |
| 95 | + And we can execute the following queries: |
| 96 | + </para> |
| 97 | + <programlisting> |
| 98 | +=# SELECT t, a <=> to_tsquery('english', 'beautiful | place') AS rank |
| 99 | + FROM test_rum |
| 100 | + WHERE a @@ to_tsquery('english', 'beautiful | place') |
| 101 | + ORDER BY a <=> to_tsquery('english', 'beautiful | place'); |
| 102 | + t | rank |
| 103 | +---------------------------------+----------- |
| 104 | + The situation is most beautiful | 0.0303964 |
| 105 | + It is a beautiful | 0.0303964 |
| 106 | + It looks like a beautiful place | 0.0607927 |
| 107 | +(3 rows) |
| 108 | + |
| 109 | +=# SELECT t, a <=> to_tsquery('english', 'place | situation') AS rank |
| 110 | + FROM test_rum |
| 111 | + WHERE a @@ to_tsquery('english', 'place | situation') |
| 112 | + ORDER BY a <=> to_tsquery('english', 'place | situation'); |
| 113 | + t | rank |
| 114 | +---------------------------------+----------- |
| 115 | + The situation is most beautiful | 0.0303964 |
| 116 | + It looks like a beautiful place | 0.0303964 |
| 117 | +(2 rows) |
| 118 | +</programlisting> |
| 119 | + </sect2> |
| 120 | + <sect2 id="rum-authors"> |
| 121 | + <title>Authors</title> |
| 122 | + <para> |
| 123 | + Alexander Korotkov <email>a.korotkov@postgrespro.ru</email> |
| 124 | + Postgres Professional Ltd., Russia |
| 125 | + </para> |
| 126 | + <para> |
| 127 | + Oleg Bartunov <email>oleg@sai.msu.su</email> Postgres Professional |
| 128 | + Ltd., Russia |
| 129 | + </para> |
| 130 | + <para> |
| 131 | + Teodor Sigaev <email>teodor@sigaev.ru</email> Postgres |
| 132 | + Professional Ltd., Russia |
| 133 | + </para> |
| 134 | + </sect2> |
| 135 | +</sect1> |
0 commit comments