File: expr.sql

package info (click to toggle)
postgresql-rum 1.3.14-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,956 kB
  • sloc: ansic: 29,184; sql: 6,614; perl: 546; python: 97; makefile: 68; sh: 64
file content (21 lines) | stat: -rw-r--r-- 739 bytes parent folder | download
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;