Created
September 7, 2020 15:20
-
-
Save therockstorm/668f6c9e93789f7a4deaace71fcb7842 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE IF NOT EXISTS search_idx | |
( | |
id BIGINT PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY, | |
key_str TEXT NOT NULL, | |
val_str TEXT NOT NULL, | |
val_int INT, | |
val_date TIMESTAMPTZ | |
); | |
CREATE INDEX search_idx_key_str_idx ON search_idx | |
USING GIN ((setweight(to_tsvector('english'::regconfig, key_str), 'A') || | |
setweight(to_tsvector('english'::regconfig, val_str), 'B'))); | |
SELECT * | |
FROM search_idx | |
WHERE (setweight(to_tsvector('english'::regconfig, key_str), 'A') || | |
setweight(to_tsvector('english'::regconfig, val_str), 'B')) @@ to_tsquery('english'::regconfig, 'qui:AB') | |
LIMIT 10000; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment