CREATE OR REPLACE FUNCTION plainto_or_tsquery (TEXT) RETURNS tsquery AS $$ SELECT to_tsquery (regexp_replace ($1, E ' [\\s \' | :& ()!] + ', ' | ', ' g ')); $$ LANGUAGE SQL STRICT IMMUTABLE;source: http://www.progtown.com/topic700061-selection-of-keywords-to-the-text.html
Tuesday, June 7, 2016
plainto_or_tsquery
tsvector update table dan create index
Labels:
fts,
postgresql
0
comments
Update table menggunakan tsvector
UPDATE table SET (col1_keywords, col2_keywords, col3_keywords) = (to_tsvector(col1), to_tsvector(col1 || ' ' || col2), to_tsvector(col1 || ' ' || col2 || ' ' || col3))Kemudian, create index untuk column keyword tersebut.
CREATE INDEX namadma_dun_par_idx ON daerahmengundifull USING gin(namadma_dun_par_keywords)
Subscribe to:
Posts (Atom)