File: expr.sql

package info (click to toggle)
postgresql-rum 1.3.15-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,928 kB
  • sloc: ansic: 29,212; sql: 3,876; perl: 250; makefile: 75; sh: 65
file content (21 lines) | stat: -rw-r--r-- 739 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
CREATE TABLE documents (
    en text not null,
    score float not null,
    textsearch_index_en_col tsvector
);

INSERT INTO documents VALUES ('the pet cat is in the shed', 56, to_tsvector('english', 'the pet cat is in the shed'));

CREATE INDEX textsearch_index_en ON documents
    USING rum (textsearch_index_en_col rum_tsvector_addon_ops, score)
    WITH (attach = 'score', to = 'textsearch_index_en_col');

SET enable_seqscan=off;
-- should be 1 row
SELECT * FROM documents WHERE textsearch_index_en_col @@ ('pet'::tsquery <-> ('dog'::tsquery || 'cat'::tsquery));

SET enable_seqscan=on;
-- 1 row
SELECT * FROM documents WHERE textsearch_index_en_col @@ ('pet'::tsquery <-> ('dog'::tsquery || 'cat'::tsquery));

DROP TABLE documents;