wget -q -O - http://www.xunsearch.com/scws/down/scws-1.2.2.tar.bz2 | tar xf - cd scws-1.2.2 ; ./configure ; make install
git clone https://github.com/amutu/zhparser.git SCWS_HOME=/usr/local make && make install
psql -U postgres -d test_dbname -c 'CREATE EXTENSION zhparser'
test_dbname=# CREATE TEXT SEARCH CONFIGURATION testzhcfg (PARSER = zhparser); test_dbname=# ALTER TEXT SEARCH CONFIGURATION testzhcfg ADD MAPPING FOR n,v,a,i,e,l WITH simple;
CREATE TABLE messages ( title text, body text );
INSERT INTO messages VALUES('批发新', '款新婴幼');
test_dbname=# ALTER TABLE messages ADD COLUMN tsv tsvector;
test_dbname=# CREATE INDEX tsv_idx ON messages USING gin(tsv);
test_dbname=# CREATE TRIGGER tsvectorupdate BEFORE INSERT OR UPDATE ON messages FOR EACH ROW EXECUTE PROCEDURE tsvector_update_trigger( tsv, 'public.testzhcfg', title, body );
test_dbname=# UPDATE messages SET title=title, body=body;
Source: https://habr.com/ru/post/301820/
All Articles