mirror of
https://github.com/postgres/postgres.git
synced 2025-07-31 22:04:40 +03:00
Replace the now-incompatible-with-core contrib/tsearch2 module with a
compatibility package. This supports importing dumps from past versions using tsearch2, and provides the old names and API for most functions that were changed. (rewrite(ARRAY[...]) is a glaring omission, though.) Pavel Stehule and Tom Lane
This commit is contained in:
@ -88,9 +88,9 @@ Moscow moskva | moscow
|
||||
\set ECHO all
|
||||
|
||||
alter table test_tsquery add column keyword tsquery;
|
||||
update test_tsquery set keyword = to_tsquery('default', txtkeyword);
|
||||
update test_tsquery set keyword = to_tsquery('english', txtkeyword);
|
||||
alter table test_tsquery add column sample tsquery;
|
||||
update test_tsquery set sample = to_tsquery('default', txtsample::text);
|
||||
update test_tsquery set sample = to_tsquery('english', txtsample::text);
|
||||
|
||||
create unique index bt_tsq on test_tsquery (keyword);
|
||||
|
||||
@ -116,21 +116,10 @@ select rewrite('moscow', 'select keyword, sample from test_tsquery'::text );
|
||||
select rewrite('moscow & hotel', 'select keyword, sample from test_tsquery'::text );
|
||||
select rewrite('bar & new & qq & foo & york', 'select keyword, sample from test_tsquery'::text );
|
||||
|
||||
select rewrite( ARRAY['moscow', keyword, sample] ) from test_tsquery;
|
||||
select rewrite( ARRAY['moscow & hotel', keyword, sample] ) from test_tsquery;
|
||||
select rewrite( ARRAY['bar & new & qq & foo & york', keyword, sample] ) from test_tsquery;
|
||||
|
||||
|
||||
select keyword from test_tsquery where keyword @> 'new';
|
||||
select keyword from test_tsquery where keyword @> 'moscow';
|
||||
select keyword from test_tsquery where keyword <@ 'new';
|
||||
select keyword from test_tsquery where keyword <@ 'moscow';
|
||||
select rewrite( ARRAY[query, keyword, sample] ) from test_tsquery, to_tsquery('default', 'moscow') as query where keyword <@ query;
|
||||
select rewrite( ARRAY[query, keyword, sample] ) from test_tsquery, to_tsquery('default', 'moscow & hotel') as query where keyword <@ query;
|
||||
select rewrite( ARRAY[query, keyword, sample] ) from test_tsquery, to_tsquery('default', 'bar & new & qq & foo & york') as query where keyword <@ query;
|
||||
select rewrite( ARRAY[query, keyword, sample] ) from test_tsquery, to_tsquery('default', 'moscow') as query where query @> keyword;
|
||||
select rewrite( ARRAY[query, keyword, sample] ) from test_tsquery, to_tsquery('default', 'moscow & hotel') as query where query @> keyword;
|
||||
select rewrite( ARRAY[query, keyword, sample] ) from test_tsquery, to_tsquery('default', 'bar & new & qq & foo & york') as query where query @> keyword;
|
||||
|
||||
create index qq on test_tsquery using gist (keyword gist_tp_tsquery_ops);
|
||||
set enable_seqscan='off';
|
||||
@ -139,48 +128,43 @@ select keyword from test_tsquery where keyword @> 'new';
|
||||
select keyword from test_tsquery where keyword @> 'moscow';
|
||||
select keyword from test_tsquery where keyword <@ 'new';
|
||||
select keyword from test_tsquery where keyword <@ 'moscow';
|
||||
select rewrite( ARRAY[query, keyword, sample] ) from test_tsquery, to_tsquery('default', 'moscow') as query where keyword <@ query;
|
||||
select rewrite( ARRAY[query, keyword, sample] ) from test_tsquery, to_tsquery('default', 'moscow & hotel') as query where keyword <@ query;
|
||||
select rewrite( ARRAY[query, keyword, sample] ) from test_tsquery, to_tsquery('default', 'bar & new & qq & foo & york') as query where keyword <@ query;
|
||||
select rewrite( ARRAY[query, keyword, sample] ) from test_tsquery, to_tsquery('default', 'moscow') as query where query @> keyword;
|
||||
select rewrite( ARRAY[query, keyword, sample] ) from test_tsquery, to_tsquery('default', 'moscow & hotel') as query where query @> keyword;
|
||||
select rewrite( ARRAY[query, keyword, sample] ) from test_tsquery, to_tsquery('default', 'bar & new & qq & foo & york') as query where query @> keyword;
|
||||
|
||||
set enable_seqscan='on';
|
||||
|
||||
|
||||
|
||||
select lexize('simple', 'ASD56 hsdkf');
|
||||
select lexize('en_stem', 'SKIES Problems identity');
|
||||
select lexize('english_stem', 'SKIES Problems identity');
|
||||
|
||||
select * from token_type('default');
|
||||
select * from parse('default', '345 qwe@efd.r '' http://www.com/ http://aew.werc.ewr/?ad=qwe&dw 1aew.werc.ewr/?ad=qwe&dw 2aew.werc.ewr http://3aew.werc.ewr/?ad=qwe&dw http://4aew.werc.ewr http://5aew.werc.ewr:8100/? ad=qwe&dw 6aew.werc.ewr:8100/?ad=qwe&dw 7aew.werc.ewr:8100/?ad=qwe&dw=%20%32 +4.0e-10 qwe qwe qwqwe 234.435 455 5.005 teodor@stack.net qwe-wer asdf <fr>qwer jf sdjk<we hjwer <werrwe> ewr1> ewri2 <a href="qwe<qwe>">
|
||||
/usr/local/fff /awdf/dwqe/4325 rewt/ewr wefjn /wqe-324/ewr gist.h gist.h.c gist.c. readline 4.2 4.2. 4.2, readline-4.2 readline-4.2. 234
|
||||
<i <b> wow < jqw <> qwerty');
|
||||
|
||||
SELECT to_tsvector('default', '345 qwe@efd.r '' http://www.com/ http://aew.werc.ewr/?ad=qwe&dw 1aew.werc.ewr/?ad=qwe&dw 2aew.werc.ewr http://3aew.werc.ewr/?ad=qwe&dw http://4aew.werc.ewr http://5aew.werc.ewr:8100/? ad=qwe&dw 6aew.werc.ewr:8100/?ad=qwe&dw 7aew.werc.ewr:8100/?ad=qwe&dw=%20%32 +4.0e-10 qwe qwe qwqwe 234.435 455 5.005 teodor@stack.net qwe-wer asdf <fr>qwer jf sdjk<we hjwer <werrwe> ewr1> ewri2 <a href="qwe<qwe>">
|
||||
SELECT to_tsvector('english', '345 qwe@efd.r '' http://www.com/ http://aew.werc.ewr/?ad=qwe&dw 1aew.werc.ewr/?ad=qwe&dw 2aew.werc.ewr http://3aew.werc.ewr/?ad=qwe&dw http://4aew.werc.ewr http://5aew.werc.ewr:8100/? ad=qwe&dw 6aew.werc.ewr:8100/?ad=qwe&dw 7aew.werc.ewr:8100/?ad=qwe&dw=%20%32 +4.0e-10 qwe qwe qwqwe 234.435 455 5.005 teodor@stack.net qwe-wer asdf <fr>qwer jf sdjk<we hjwer <werrwe> ewr1> ewri2 <a href="qwe<qwe>">
|
||||
/usr/local/fff /awdf/dwqe/4325 rewt/ewr wefjn /wqe-324/ewr gist.h gist.h.c gist.c. readline 4.2 4.2. 4.2, readline-4.2 readline-4.2. 234
|
||||
<i <b> wow < jqw <> qwerty');
|
||||
|
||||
SELECT length(to_tsvector('default', '345 qw'));
|
||||
SELECT length(to_tsvector('english', '345 qw'));
|
||||
|
||||
SELECT length(to_tsvector('default', '345 qwe@efd.r '' http://www.com/ http://aew.werc.ewr/?ad=qwe&dw 1aew.werc.ewr/?ad=qwe&dw 2aew.werc.ewr http://3aew.werc.ewr/?ad=qwe&dw http://4aew.werc.ewr http://5aew.werc.ewr:8100/? ad=qwe&dw 6aew.werc.ewr:8100/?ad=qwe&dw 7aew.werc.ewr:8100/?ad=qwe&dw=%20%32 +4.0e-10 qwe qwe qwqwe 234.435 455 5.005 teodor@stack.net qwe-wer asdf <fr>qwer jf sdjk<we hjwer <werrwe> ewr1> ewri2 <a href="qwe<qwe>">
|
||||
SELECT length(to_tsvector('english', '345 qwe@efd.r '' http://www.com/ http://aew.werc.ewr/?ad=qwe&dw 1aew.werc.ewr/?ad=qwe&dw 2aew.werc.ewr http://3aew.werc.ewr/?ad=qwe&dw http://4aew.werc.ewr http://5aew.werc.ewr:8100/? ad=qwe&dw 6aew.werc.ewr:8100/?ad=qwe&dw 7aew.werc.ewr:8100/?ad=qwe&dw=%20%32 +4.0e-10 qwe qwe qwqwe 234.435 455 5.005 teodor@stack.net qwe-wer asdf <fr>qwer jf sdjk<we hjwer <werrwe> ewr1> ewri2 <a href="qwe<qwe>">
|
||||
/usr/local/fff /awdf/dwqe/4325 rewt/ewr wefjn /wqe-324/ewr gist.h gist.h.c gist.c. readline 4.2 4.2. 4.2, readline-4.2 readline-4.2. 234
|
||||
<i <b> wow < jqw <> qwerty'));
|
||||
|
||||
|
||||
select to_tsquery('default', 'qwe & sKies ');
|
||||
select to_tsquery('english', 'qwe & sKies ');
|
||||
select to_tsquery('simple', 'qwe & sKies ');
|
||||
select to_tsquery('default', '''the wether'':dc & '' sKies '':BC ');
|
||||
select to_tsquery('default', 'asd&(and|fghj)');
|
||||
select to_tsquery('default', '(asd&and)|fghj');
|
||||
select to_tsquery('default', '(asd&!and)|fghj');
|
||||
select to_tsquery('default', '(the|and&(i&1))&fghj');
|
||||
select to_tsquery('english', '''the wether'':dc & '' sKies '':BC ');
|
||||
select to_tsquery('english', 'asd&(and|fghj)');
|
||||
select to_tsquery('english', '(asd&and)|fghj');
|
||||
select to_tsquery('english', '(asd&!and)|fghj');
|
||||
select to_tsquery('english', '(the|and&(i&1))&fghj');
|
||||
|
||||
select plainto_tsquery('default', 'the and z 1))& fghj');
|
||||
select plainto_tsquery('default', 'foo bar') && plainto_tsquery('default', 'asd');
|
||||
select plainto_tsquery('default', 'foo bar') || plainto_tsquery('default', 'asd fg');
|
||||
select plainto_tsquery('default', 'foo bar') || !!plainto_tsquery('default', 'asd fg');
|
||||
select plainto_tsquery('default', 'foo bar') && 'asd | fg';
|
||||
select plainto_tsquery('english', 'the and z 1))& fghj');
|
||||
select plainto_tsquery('english', 'foo bar') && plainto_tsquery('english', 'asd');
|
||||
select plainto_tsquery('english', 'foo bar') || plainto_tsquery('english', 'asd fg');
|
||||
select plainto_tsquery('english', 'foo bar') || !!plainto_tsquery('english', 'asd fg');
|
||||
select plainto_tsquery('english', 'foo bar') && 'asd | fg';
|
||||
|
||||
select 'a b:89 ca:23A,64b d:34c'::tsvector @@ 'd:AC & ca';
|
||||
select 'a b:89 ca:23A,64b d:34c'::tsvector @@ 'd:AC & ca:B';
|
||||
@ -209,7 +193,7 @@ SELECT count(*) FROM test_tsvector WHERE a @@ 'eq|yt';
|
||||
SELECT count(*) FROM test_tsvector WHERE a @@ '(eq&yt)|(wr&qh)';
|
||||
SELECT count(*) FROM test_tsvector WHERE a @@ '(eq|yt)&(wr|qh)';
|
||||
|
||||
select set_curcfg('default');
|
||||
select set_curcfg('english');
|
||||
|
||||
CREATE TRIGGER tsvectorupdate
|
||||
BEFORE UPDATE OR INSERT ON test_tsvector
|
||||
@ -225,11 +209,7 @@ UPDATE test_tsvector SET t = null WHERE t = '345 qwerty';
|
||||
|
||||
SELECT count(*) FROM test_tsvector WHERE a @@ to_tsquery('345&qwerty');
|
||||
|
||||
drop trigger tsvectorupdate on test_tsvector;
|
||||
create function wow(text) returns text as 'select $1 || '' copyright''; ' language sql;
|
||||
create trigger tsvectorupdate before update or insert on test_tsvector
|
||||
for each row execute procedure tsearch2(a, wow, t);
|
||||
insert into test_tsvector (t) values ('345 qwerty');
|
||||
insert into test_tsvector (t) values ('345 qwerty copyright');
|
||||
select count(*) FROM test_tsvector WHERE a @@ to_tsquery('345&qwerty');
|
||||
select count(*) FROM test_tsvector WHERE a @@ to_tsquery('copyright');
|
||||
|
||||
@ -251,8 +231,7 @@ select * from stat('select a from test_tsvector','c') order by ndoc desc, nentry
|
||||
select * from stat('select a from test_tsvector','d') order by ndoc desc, nentry desc, word;
|
||||
select * from stat('select a from test_tsvector','ad') order by ndoc desc, nentry desc, word;
|
||||
|
||||
select reset_tsearch();
|
||||
select to_tsquery('default', 'skies & books');
|
||||
select to_tsquery('english', 'skies & books');
|
||||
|
||||
select rank_cd(to_tsvector('Erosion It took the sea a thousand years,
|
||||
A thousand years to trace
|
||||
@ -284,36 +263,6 @@ The sculpture of these granite seams,
|
||||
Upon a woman s face. E. J. Pratt (1882 1964)
|
||||
'), to_tsquery('sea'));
|
||||
|
||||
select get_covers(to_tsvector('Erosion It took the sea a thousand years,
|
||||
A thousand years to trace
|
||||
The granite features of this cliff
|
||||
In crag and scarp and base.
|
||||
It took the sea an hour one night
|
||||
An hour of storm to place
|
||||
The sculpture of these granite seams,
|
||||
Upon a woman s face. E. J. Pratt (1882 1964)
|
||||
'), to_tsquery('sea&thousand&years'));
|
||||
|
||||
select get_covers(to_tsvector('Erosion It took the sea a thousand years,
|
||||
A thousand years to trace
|
||||
The granite features of this cliff
|
||||
In crag and scarp and base.
|
||||
It took the sea an hour one night
|
||||
An hour of storm to place
|
||||
The sculpture of these granite seams,
|
||||
Upon a woman s face. E. J. Pratt (1882 1964)
|
||||
'), to_tsquery('granite&sea'));
|
||||
|
||||
select get_covers(to_tsvector('Erosion It took the sea a thousand years,
|
||||
A thousand years to trace
|
||||
The granite features of this cliff
|
||||
In crag and scarp and base.
|
||||
It took the sea an hour one night
|
||||
An hour of storm to place
|
||||
The sculpture of these granite seams,
|
||||
Upon a woman s face. E. J. Pratt (1882 1964)
|
||||
'), to_tsquery('sea'));
|
||||
|
||||
select headline('Erosion It took the sea a thousand years,
|
||||
A thousand years to trace
|
||||
The granite features of this cliff
|
||||
@ -359,7 +308,7 @@ ff-bg
|
||||
</html>',
|
||||
to_tsquery('sea&foo'), 'HighlightAll=true');
|
||||
--check debug
|
||||
select * from ts_debug('Tsearch module for PostgreSQL 7.3.3');
|
||||
select * from public.ts_debug('Tsearch module for PostgreSQL 7.3.3');
|
||||
|
||||
--check ordering
|
||||
insert into test_tsvector values (null, null);
|
||||
|
Reference in New Issue
Block a user