Uppercase keywords in regression tsearch test scripts.

This commit is contained in:
Bruce Momjian 2007-08-21 15:41:13 +00:00
parent a4be395364
commit 1c36de33b0
4 changed files with 234 additions and 235 deletions

View File

@ -131,8 +131,8 @@ SELECT count(*) FROM test_tsvector WHERE a @@ '(eq|yt)&(wr|qh)';
(1 row) (1 row)
RESET enable_seqscan; RESET enable_seqscan;
drop index wowidx; DROP INDEX wowidx;
create index wowidx on test_tsvector using gin (a); CREATE INDEX wowidx ON test_tsvector USING gin (a);
SET enable_seqscan=OFF; SET enable_seqscan=OFF;
SELECT count(*) FROM test_tsvector WHERE a @@ 'wr|qh'; SELECT count(*) FROM test_tsvector WHERE a @@ 'wr|qh';
count count
@ -172,8 +172,8 @@ SELECT count(*) FROM test_tsvector WHERE a @@ '(eq|yt)&(wr|qh)';
RESET enable_seqscan; RESET enable_seqscan;
insert into test_tsvector values ('???', 'DFG:1A,2B,6C,10 FGH'); INSERT INTO test_tsvector VALUES ('???', 'DFG:1A,2B,6C,10 FGH');
select * from ts_stat('select a from test_tsvector') order by ndoc desc, nentry desc, word limit 10; SELECT * FROM ts_stat('SELECT a FROM test_tsvector') ORDER BY ndoc DESC, nentry DESC, word LIMIT 10;
word | ndoc | nentry word | ndoc | nentry
------+------+-------- ------+------+--------
qq | 108 | 108 qq | 108 | 108
@ -188,26 +188,26 @@ select * from ts_stat('select a from test_tsvector') order by ndoc desc, nentry
qr | 92 | 92 qr | 92 | 92
(10 rows) (10 rows)
select * from ts_stat('select a from test_tsvector', 'AB') order by ndoc desc, nentry desc, word; SELECT * FROM ts_stat('SELECT a FROM test_tsvector', 'AB') ORDER BY ndoc DESC, nentry DESC, word;
word | ndoc | nentry word | ndoc | nentry
------+------+-------- ------+------+--------
DFG | 1 | 2 DFG | 1 | 2
(1 row) (1 row)
--dictionaries and to_tsvector --dictionaries and to_tsvector
select ts_lexize('english', 'skies'); SELECT ts_lexize('english', 'skies');
ts_lexize ts_lexize
----------- -----------
{sky} {sky}
(1 row) (1 row)
select ts_lexize('english', 'identity'); SELECT ts_lexize('english', 'identity');
ts_lexize ts_lexize
----------- -----------
{ident} {ident}
(1 row) (1 row)
select * from ts_token_type('default'); SELECT * FROM ts_token_type('default');
tokid | alias | description tokid | alias | description
-------+--------------+----------------------------------- -------+--------------+-----------------------------------
1 | lword | Latin word 1 | lword | Latin word
@ -235,7 +235,7 @@ select * from ts_token_type('default');
23 | entity | HTML Entity 23 | entity | HTML Entity
(23 rows) (23 rows)
select * from ts_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>"> SELECT * FROM ts_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 /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'); <i <b> wow < jqw <> qwerty');
tokid | token tokid | token
@ -379,7 +379,7 @@ select * from ts_parse('default', '345 qwe@efd.r '' http://www.com/ http://aew.w
1 | qwerty 1 | qwerty
(135 rows) (135 rows)
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>"> 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 /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'); <i <b> wow < jqw <> qwerty');
to_tsvector to_tsvector
@ -387,7 +387,7 @@ select to_tsvector('english', '345 qwe@efd.r '' http://www.com/ http://aew.werc.
'ad':17 'dw':19 'jf':39 '234':63 '345':1 '4.2':54,55,56,59,62 '455':31 'jqw':66 'qwe':2,18,27,28,35 'wer':36 'wow':65 'asdf':37 'ewr1':43 'qwer':38 'sdjk':40 '5.005':32 'efd.r':3 'ewri2':44 'hjwer':42 'qwqwe':29 'wefjn':48 'gist.c':52 'gist.h':50 'qwerti':67 '234.435':30 'qwe-wer':34 'readlin':53,58,61 'www.com':4 '+4.0e-10':26 'gist.h.c':51 'rewt/ewr':47 '/?ad=qwe&dw':7,10,14,22 '/wqe-324/ewr':49 'aew.werc.ewr':6 'readline-4.2':57,60 '1aew.werc.ewr':9 '2aew.werc.ewr':11 '3aew.werc.ewr':13 '4aew.werc.ewr':15 '/usr/local/fff':45 '/awdf/dwqe/4325':46 'teodor@stack.net':33 '/?ad=qwe&dw=%20%32':25 '5aew.werc.ewr:8100':16 '6aew.werc.ewr:8100':21 '7aew.werc.ewr:8100':24 'aew.werc.ewr/?ad=qwe&dw':5 '1aew.werc.ewr/?ad=qwe&dw':8 '3aew.werc.ewr/?ad=qwe&dw':12 '6aew.werc.ewr:8100/?ad=qwe&dw':20 '7aew.werc.ewr:8100/?ad=qwe&dw=%20%32':23 'ad':17 'dw':19 'jf':39 '234':63 '345':1 '4.2':54,55,56,59,62 '455':31 'jqw':66 'qwe':2,18,27,28,35 'wer':36 'wow':65 'asdf':37 'ewr1':43 'qwer':38 'sdjk':40 '5.005':32 'efd.r':3 'ewri2':44 'hjwer':42 'qwqwe':29 'wefjn':48 'gist.c':52 'gist.h':50 'qwerti':67 '234.435':30 'qwe-wer':34 'readlin':53,58,61 'www.com':4 '+4.0e-10':26 'gist.h.c':51 'rewt/ewr':47 '/?ad=qwe&dw':7,10,14,22 '/wqe-324/ewr':49 'aew.werc.ewr':6 'readline-4.2':57,60 '1aew.werc.ewr':9 '2aew.werc.ewr':11 '3aew.werc.ewr':13 '4aew.werc.ewr':15 '/usr/local/fff':45 '/awdf/dwqe/4325':46 'teodor@stack.net':33 '/?ad=qwe&dw=%20%32':25 '5aew.werc.ewr:8100':16 '6aew.werc.ewr:8100':21 '7aew.werc.ewr:8100':24 'aew.werc.ewr/?ad=qwe&dw':5 '1aew.werc.ewr/?ad=qwe&dw':8 '3aew.werc.ewr/?ad=qwe&dw':12 '6aew.werc.ewr:8100/?ad=qwe&dw':20 '7aew.werc.ewr:8100/?ad=qwe&dw=%20%32':23
(1 row) (1 row)
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>"> 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 /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')); <i <b> wow < jqw <> qwerty'));
length length
@ -396,79 +396,79 @@ select length(to_tsvector('english', '345 qwe@efd.r '' http://www.com/ http://ae
(1 row) (1 row)
-- to_tsquery -- to_tsquery
select to_tsquery('english', 'qwe & sKies '); SELECT to_tsquery('english', 'qwe & sKies ');
to_tsquery to_tsquery
--------------- ---------------
'qwe' & 'sky' 'qwe' & 'sky'
(1 row) (1 row)
select to_tsquery('simple', 'qwe & sKies '); SELECT to_tsquery('simple', 'qwe & sKies ');
to_tsquery to_tsquery
----------------- -----------------
'qwe' & 'skies' 'qwe' & 'skies'
(1 row) (1 row)
select to_tsquery('english', '''the wether'':dc & '' sKies '':BC '); SELECT to_tsquery('english', '''the wether'':dc & '' sKies '':BC ');
to_tsquery to_tsquery
------------------------ ------------------------
'wether':CD & 'sky':BC 'wether':CD & 'sky':BC
(1 row) (1 row)
select to_tsquery('english', 'asd&(and|fghj)'); SELECT to_tsquery('english', 'asd&(and|fghj)');
to_tsquery to_tsquery
---------------- ----------------
'asd' & 'fghj' 'asd' & 'fghj'
(1 row) (1 row)
select to_tsquery('english', '(asd&and)|fghj'); SELECT to_tsquery('english', '(asd&and)|fghj');
to_tsquery to_tsquery
---------------- ----------------
'asd' | 'fghj' 'asd' | 'fghj'
(1 row) (1 row)
select to_tsquery('english', '(asd&!and)|fghj'); SELECT to_tsquery('english', '(asd&!and)|fghj');
to_tsquery to_tsquery
---------------- ----------------
'asd' | 'fghj' 'asd' | 'fghj'
(1 row) (1 row)
select to_tsquery('english', '(the|and&(i&1))&fghj'); SELECT to_tsquery('english', '(the|and&(i&1))&fghj');
to_tsquery to_tsquery
-------------- --------------
'1' & 'fghj' '1' & 'fghj'
(1 row) (1 row)
select plainto_tsquery('english', 'the and z 1))& fghj'); SELECT plainto_tsquery('english', 'the and z 1))& fghj');
plainto_tsquery plainto_tsquery
-------------------- --------------------
'z' & '1' & 'fghj' 'z' & '1' & 'fghj'
(1 row) (1 row)
select plainto_tsquery('english', 'foo bar') && plainto_tsquery('english', 'asd'); SELECT plainto_tsquery('english', 'foo bar') && plainto_tsquery('english', 'asd');
?column? ?column?
----------------------- -----------------------
'foo' & 'bar' & 'asd' 'foo' & 'bar' & 'asd'
(1 row) (1 row)
select plainto_tsquery('english', 'foo bar') || plainto_tsquery('english', 'asd fg'); SELECT plainto_tsquery('english', 'foo bar') || plainto_tsquery('english', 'asd fg');
?column? ?column?
------------------------------ ------------------------------
'foo' & 'bar' | 'asd' & 'fg' 'foo' & 'bar' | 'asd' & 'fg'
(1 row) (1 row)
select plainto_tsquery('english', 'foo bar') || !!plainto_tsquery('english', 'asd fg'); SELECT plainto_tsquery('english', 'foo bar') || !!plainto_tsquery('english', 'asd fg');
?column? ?column?
----------------------------------- -----------------------------------
'foo' & 'bar' | !( 'asd' & 'fg' ) 'foo' & 'bar' | !( 'asd' & 'fg' )
(1 row) (1 row)
select plainto_tsquery('english', 'foo bar') && 'asd | fg'; SELECT plainto_tsquery('english', 'foo bar') && 'asd | fg';
?column? ?column?
---------------------------------- ----------------------------------
'foo' & 'bar' & ( 'asd' | 'fg' ) 'foo' & 'bar' & ( 'asd' | 'fg' )
(1 row) (1 row)
select ts_rank_cd(to_tsvector('english', 'Erosion It took the sea a thousand years, SELECT ts_rank_cd(to_tsvector('english', 'Erosion It took the sea a thousand years,
A thousand years to trace A thousand years to trace
The granite features of this cliff The granite features of this cliff
In crag and scarp and base. In crag and scarp and base.
@ -482,7 +482,7 @@ Upon a woman s face. E. J. Pratt (1882 1964)
0.0555556 0.0555556
(1 row) (1 row)
select ts_rank_cd(to_tsvector('english', 'Erosion It took the sea a thousand years, SELECT ts_rank_cd(to_tsvector('english', 'Erosion It took the sea a thousand years,
A thousand years to trace A thousand years to trace
The granite features of this cliff The granite features of this cliff
In crag and scarp and base. In crag and scarp and base.
@ -496,7 +496,7 @@ Upon a woman s face. E. J. Pratt (1882 1964)
0.0238095 0.0238095
(1 row) (1 row)
select ts_rank_cd(to_tsvector('english', 'Erosion It took the sea a thousand years, SELECT ts_rank_cd(to_tsvector('english', 'Erosion It took the sea a thousand years,
A thousand years to trace A thousand years to trace
The granite features of this cliff The granite features of this cliff
In crag and scarp and base. In crag and scarp and base.
@ -511,7 +511,7 @@ Upon a woman s face. E. J. Pratt (1882 1964)
(1 row) (1 row)
--headline tests --headline tests
select ts_headline('english', 'Erosion It took the sea a thousand years, SELECT ts_headline('english', 'Erosion It took the sea a thousand years,
A thousand years to trace A thousand years to trace
The granite features of this cliff The granite features of this cliff
In crag and scarp and base. In crag and scarp and base.
@ -527,7 +527,7 @@ Upon a woman s face. E. J. Pratt (1882 1964)
The granite features of this cliff The granite features of this cliff
(1 row) (1 row)
select ts_headline('english', 'Erosion It took the sea a thousand years, SELECT ts_headline('english', 'Erosion It took the sea a thousand years,
A thousand years to trace A thousand years to trace
The granite features of this cliff The granite features of this cliff
In crag and scarp and base. In crag and scarp and base.
@ -543,7 +543,7 @@ Upon a woman s face. E. J. Pratt (1882 1964)
The <b>granite</b> features of this cliff The <b>granite</b> features of this cliff
(1 row) (1 row)
select ts_headline('english', 'Erosion It took the sea a thousand years, SELECT ts_headline('english', 'Erosion It took the sea a thousand years,
A thousand years to trace A thousand years to trace
The granite features of this cliff The granite features of this cliff
In crag and scarp and base. In crag and scarp and base.
@ -559,7 +559,7 @@ Upon a woman s face. E. J. Pratt (1882 1964)
The granite features of this cliff The granite features of this cliff
(1 row) (1 row)
select ts_headline('english', ' SELECT ts_headline('english', '
<html> <html>
<!-- some comment --> <!-- some comment -->
<body> <body>
@ -589,232 +589,232 @@ to_tsquery('english', 'sea&foo'), 'HighlightAll=true');
(1 row) (1 row)
--Rewrite sub system --Rewrite sub system
create table test_tsquery (txtkeyword text, txtsample text); CREATE TABLE test_tsquery (txtkeyword TEXT, txtsample TEXT);
\set ECHO none \set ECHO none
alter table test_tsquery add column keyword tsquery; ALTER TABLE test_tsquery ADD COLUMN keyword tsquery;
update test_tsquery set keyword = to_tsquery('english', txtkeyword); UPDATE test_tsquery SET keyword = to_tsquery('english', txtkeyword);
alter table test_tsquery add column sample tsquery; ALTER TABLE test_tsquery ADD COLUMN sample tsquery;
update test_tsquery set sample = to_tsquery('english', txtsample::text); UPDATE test_tsquery SET sample = to_tsquery('english', txtsample::text);
select count(*) from test_tsquery where keyword < 'new & york'; SELECT COUNT(*) FROM test_tsquery WHERE keyword < 'new & york';
count count
------- -------
1 1
(1 row) (1 row)
select count(*) from test_tsquery where keyword <= 'new & york'; SELECT COUNT(*) FROM test_tsquery WHERE keyword <= 'new & york';
count count
------- -------
2 2
(1 row) (1 row)
select count(*) from test_tsquery where keyword = 'new & york'; SELECT COUNT(*) FROM test_tsquery WHERE keyword = 'new & york';
count count
------- -------
1 1
(1 row) (1 row)
select count(*) from test_tsquery where keyword >= 'new & york'; SELECT COUNT(*) FROM test_tsquery WHERE keyword >= 'new & york';
count count
------- -------
3 3
(1 row) (1 row)
select count(*) from test_tsquery where keyword > 'new & york'; SELECT COUNT(*) FROM test_tsquery WHERE keyword > 'new & york';
count count
------- -------
2 2
(1 row) (1 row)
create unique index bt_tsq on test_tsquery (keyword); CREATE UNIQUE INDEX bt_tsq ON test_tsquery (keyword);
SET enable_seqscan=OFF; SET enable_seqscan=OFF;
select count(*) from test_tsquery where keyword < 'new & york'; SELECT COUNT(*) FROM test_tsquery WHERE keyword < 'new & york';
count count
------- -------
1 1
(1 row) (1 row)
select count(*) from test_tsquery where keyword <= 'new & york'; SELECT COUNT(*) FROM test_tsquery WHERE keyword <= 'new & york';
count count
------- -------
2 2
(1 row) (1 row)
select count(*) from test_tsquery where keyword = 'new & york'; SELECT COUNT(*) FROM test_tsquery WHERE keyword = 'new & york';
count count
------- -------
1 1
(1 row) (1 row)
select count(*) from test_tsquery where keyword >= 'new & york'; SELECT COUNT(*) FROM test_tsquery WHERE keyword >= 'new & york';
count count
------- -------
3 3
(1 row) (1 row)
select count(*) from test_tsquery where keyword > 'new & york'; SELECT COUNT(*) FROM test_tsquery WHERE keyword > 'new & york';
count count
------- -------
2 2
(1 row) (1 row)
RESET enable_seqscan; RESET enable_seqscan;
select ts_rewrite('foo & bar & qq & new & york', 'new & york'::tsquery, 'big & apple | nyc | new & york & city'); SELECT ts_rewrite('foo & bar & qq & new & york', 'new & york'::tsquery, 'big & apple | nyc | new & york & city');
ts_rewrite ts_rewrite
---------------------------------------------------------------------------------- ----------------------------------------------------------------------------------
'foo' & 'bar' & 'qq' & ( 'city' & 'new' & 'york' | ( 'nyc' | 'big' & 'apple' ) ) 'foo' & 'bar' & 'qq' & ( 'city' & 'new' & 'york' | ( 'nyc' | 'big' & 'apple' ) )
(1 row) (1 row)
select ts_rewrite('moscow', 'select keyword, sample from test_tsquery'::text ); SELECT ts_rewrite('moscow', 'SELECT keyword, sample FROM test_tsquery'::text );
ts_rewrite ts_rewrite
--------------------- ---------------------
'moskva' | 'moscow' 'moskva' | 'moscow'
(1 row) (1 row)
select ts_rewrite('moscow & hotel', 'select keyword, sample from test_tsquery'::text ); SELECT ts_rewrite('moscow & hotel', 'SELECT keyword, sample FROM test_tsquery'::text );
ts_rewrite ts_rewrite
----------------------------------- -----------------------------------
( 'moskva' | 'moscow' ) & 'hotel' ( 'moskva' | 'moscow' ) & 'hotel'
(1 row) (1 row)
select ts_rewrite('bar & new & qq & foo & york', 'select keyword, sample from test_tsquery'::text ); SELECT ts_rewrite('bar & new & qq & foo & york', 'SELECT keyword, sample FROM test_tsquery'::text );
ts_rewrite ts_rewrite
------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------
'citi' & 'foo' & ( 'bar' | 'qq' ) & ( 'nyc' | ( 'big' & 'appl' | 'new' & 'york' ) ) 'citi' & 'foo' & ( 'bar' | 'qq' ) & ( 'nyc' | ( 'big' & 'appl' | 'new' & 'york' ) )
(1 row) (1 row)
select ts_rewrite( ARRAY['moscow', keyword, sample] ) from test_tsquery; SELECT ts_rewrite( ARRAY['moscow', keyword, sample] ) FROM test_tsquery;
ts_rewrite ts_rewrite
--------------------- ---------------------
'moskva' | 'moscow' 'moskva' | 'moscow'
(1 row) (1 row)
select ts_rewrite( ARRAY['moscow & hotel', keyword, sample] ) from test_tsquery; SELECT ts_rewrite( ARRAY['moscow & hotel', keyword, sample] ) FROM test_tsquery;
ts_rewrite ts_rewrite
----------------------------------- -----------------------------------
( 'moskva' | 'moscow' ) & 'hotel' ( 'moskva' | 'moscow' ) & 'hotel'
(1 row) (1 row)
select ts_rewrite( ARRAY['bar & new & qq & foo & york', keyword, sample] ) from test_tsquery; SELECT ts_rewrite( ARRAY['bar & new & qq & foo & york', keyword, sample] ) FROM test_tsquery;
ts_rewrite ts_rewrite
------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------
'citi' & 'foo' & ( 'bar' | 'qq' ) & ( 'nyc' | ( 'big' & 'appl' | 'new' & 'york' ) ) 'citi' & 'foo' & ( 'bar' | 'qq' ) & ( 'nyc' | ( 'big' & 'appl' | 'new' & 'york' ) )
(1 row) (1 row)
select keyword from test_tsquery where keyword @> 'new'; SELECT keyword FROM test_tsquery WHERE keyword @> 'new';
keyword keyword
---------------- ----------------
'new' & 'york' 'new' & 'york'
(1 row) (1 row)
select keyword from test_tsquery where keyword @> 'moscow'; SELECT keyword FROM test_tsquery WHERE keyword @> 'moscow';
keyword keyword
---------- ----------
'moscow' 'moscow'
(1 row) (1 row)
select keyword from test_tsquery where keyword <@ 'new'; SELECT keyword FROM test_tsquery WHERE keyword <@ 'new';
keyword keyword
--------- ---------
(0 rows) (0 rows)
select keyword from test_tsquery where keyword <@ 'moscow'; SELECT keyword FROM test_tsquery WHERE keyword <@ 'moscow';
keyword keyword
---------- ----------
'moscow' 'moscow'
(1 row) (1 row)
select ts_rewrite( ARRAY[query, keyword, sample] ) from test_tsquery, to_tsquery('english', 'moscow') as query where keyword <@ query; SELECT ts_rewrite( ARRAY[query, keyword, sample] ) FROM test_tsquery, to_tsquery('english', 'moscow') AS query WHERE keyword <@ query;
ts_rewrite ts_rewrite
--------------------- ---------------------
'moskva' | 'moscow' 'moskva' | 'moscow'
(1 row) (1 row)
select ts_rewrite( ARRAY[query, keyword, sample] ) from test_tsquery, to_tsquery('english', 'moscow & hotel') as query where keyword <@ query; SELECT ts_rewrite( ARRAY[query, keyword, sample] ) FROM test_tsquery, to_tsquery('english', 'moscow & hotel') AS query WHERE keyword <@ query;
ts_rewrite ts_rewrite
----------------------------------- -----------------------------------
( 'moskva' | 'moscow' ) & 'hotel' ( 'moskva' | 'moscow' ) & 'hotel'
(1 row) (1 row)
select ts_rewrite( ARRAY[query, keyword, sample] ) from test_tsquery, to_tsquery('english', 'bar & new & qq & foo & york') as query where keyword <@ query; SELECT ts_rewrite( ARRAY[query, keyword, sample] ) FROM test_tsquery, to_tsquery('english', 'bar & new & qq & foo & york') AS query WHERE keyword <@ query;
ts_rewrite ts_rewrite
------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------
'citi' & 'foo' & ( 'bar' | 'qq' ) & ( 'nyc' | ( 'big' & 'appl' | 'new' & 'york' ) ) 'citi' & 'foo' & ( 'bar' | 'qq' ) & ( 'nyc' | ( 'big' & 'appl' | 'new' & 'york' ) )
(1 row) (1 row)
select ts_rewrite( ARRAY[query, keyword, sample] ) from test_tsquery, to_tsquery('english', 'moscow') as query where query @> keyword; SELECT ts_rewrite( ARRAY[query, keyword, sample] ) FROM test_tsquery, to_tsquery('english', 'moscow') AS query WHERE query @> keyword;
ts_rewrite ts_rewrite
--------------------- ---------------------
'moskva' | 'moscow' 'moskva' | 'moscow'
(1 row) (1 row)
select ts_rewrite( ARRAY[query, keyword, sample] ) from test_tsquery, to_tsquery('english', 'moscow & hotel') as query where query @> keyword; SELECT ts_rewrite( ARRAY[query, keyword, sample] ) FROM test_tsquery, to_tsquery('english', 'moscow & hotel') AS query WHERE query @> keyword;
ts_rewrite ts_rewrite
----------------------------------- -----------------------------------
( 'moskva' | 'moscow' ) & 'hotel' ( 'moskva' | 'moscow' ) & 'hotel'
(1 row) (1 row)
select ts_rewrite( ARRAY[query, keyword, sample] ) from test_tsquery, to_tsquery('english', 'bar & new & qq & foo & york') as query where query @> keyword; SELECT ts_rewrite( ARRAY[query, keyword, sample] ) FROM test_tsquery, to_tsquery('english', 'bar & new & qq & foo & york') AS query WHERE query @> keyword;
ts_rewrite ts_rewrite
------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------
'citi' & 'foo' & ( 'bar' | 'qq' ) & ( 'nyc' | ( 'big' & 'appl' | 'new' & 'york' ) ) 'citi' & 'foo' & ( 'bar' | 'qq' ) & ( 'nyc' | ( 'big' & 'appl' | 'new' & 'york' ) )
(1 row) (1 row)
create index qq on test_tsquery using gist (keyword tsquery_ops); CREATE INDEX qq ON test_tsquery USING gist (keyword tsquery_ops);
SET enable_seqscan=OFF; SET enable_seqscan=OFF;
select keyword from test_tsquery where keyword @> 'new'; SELECT keyword FROM test_tsquery WHERE keyword @> 'new';
keyword keyword
---------------- ----------------
'new' & 'york' 'new' & 'york'
(1 row) (1 row)
select keyword from test_tsquery where keyword @> 'moscow'; SELECT keyword FROM test_tsquery WHERE keyword @> 'moscow';
keyword keyword
---------- ----------
'moscow' 'moscow'
(1 row) (1 row)
select keyword from test_tsquery where keyword <@ 'new'; SELECT keyword FROM test_tsquery WHERE keyword <@ 'new';
keyword keyword
--------- ---------
(0 rows) (0 rows)
select keyword from test_tsquery where keyword <@ 'moscow'; SELECT keyword FROM test_tsquery WHERE keyword <@ 'moscow';
keyword keyword
---------- ----------
'moscow' 'moscow'
(1 row) (1 row)
select ts_rewrite( ARRAY[query, keyword, sample] ) from test_tsquery, to_tsquery('english', 'moscow') as query where keyword <@ query; SELECT ts_rewrite( ARRAY[query, keyword, sample] ) FROM test_tsquery, to_tsquery('english', 'moscow') AS query WHERE keyword <@ query;
ts_rewrite ts_rewrite
--------------------- ---------------------
'moskva' | 'moscow' 'moskva' | 'moscow'
(1 row) (1 row)
select ts_rewrite( ARRAY[query, keyword, sample] ) from test_tsquery, to_tsquery('english', 'moscow & hotel') as query where keyword <@ query; SELECT ts_rewrite( ARRAY[query, keyword, sample] ) FROM test_tsquery, to_tsquery('english', 'moscow & hotel') AS query WHERE keyword <@ query;
ts_rewrite ts_rewrite
----------------------------------- -----------------------------------
( 'moskva' | 'moscow' ) & 'hotel' ( 'moskva' | 'moscow' ) & 'hotel'
(1 row) (1 row)
select ts_rewrite( ARRAY[query, keyword, sample] ) from test_tsquery, to_tsquery('english', 'bar & new & qq & foo & york') as query where keyword <@ query; SELECT ts_rewrite( ARRAY[query, keyword, sample] ) FROM test_tsquery, to_tsquery('english', 'bar & new & qq & foo & york') AS query WHERE keyword <@ query;
ts_rewrite ts_rewrite
------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------
'citi' & 'foo' & ( 'bar' | 'qq' ) & ( 'nyc' | ( 'big' & 'appl' | 'new' & 'york' ) ) 'citi' & 'foo' & ( 'bar' | 'qq' ) & ( 'nyc' | ( 'big' & 'appl' | 'new' & 'york' ) )
(1 row) (1 row)
select ts_rewrite( ARRAY[query, keyword, sample] ) from test_tsquery, to_tsquery('english', 'moscow') as query where query @> keyword; SELECT ts_rewrite( ARRAY[query, keyword, sample] ) FROM test_tsquery, to_tsquery('english', 'moscow') AS query WHERE query @> keyword;
ts_rewrite ts_rewrite
--------------------- ---------------------
'moskva' | 'moscow' 'moskva' | 'moscow'
(1 row) (1 row)
select ts_rewrite( ARRAY[query, keyword, sample] ) from test_tsquery, to_tsquery('english', 'moscow & hotel') as query where query @> keyword; SELECT ts_rewrite( ARRAY[query, keyword, sample] ) FROM test_tsquery, to_tsquery('english', 'moscow & hotel') AS query WHERE query @> keyword;
ts_rewrite ts_rewrite
----------------------------------- -----------------------------------
( 'moskva' | 'moscow' ) & 'hotel' ( 'moskva' | 'moscow' ) & 'hotel'
(1 row) (1 row)
select ts_rewrite( ARRAY[query, keyword, sample] ) from test_tsquery, to_tsquery('english', 'bar & new & qq & foo & york') as query where query @> keyword; SELECT ts_rewrite( ARRAY[query, keyword, sample] ) FROM test_tsquery, to_tsquery('english', 'bar & new & qq & foo & york') AS query WHERE query @> keyword;
ts_rewrite ts_rewrite
------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------
'citi' & 'foo' & ( 'bar' | 'qq' ) & ( 'nyc' | ( 'big' & 'appl' | 'new' & 'york' ) ) 'citi' & 'foo' & ( 'bar' | 'qq' ) & ( 'nyc' | ( 'big' & 'appl' | 'new' & 'york' ) )
@ -822,39 +822,39 @@ select ts_rewrite( ARRAY[query, keyword, sample] ) from test_tsquery, to_tsquery
RESET enable_seqscan; RESET enable_seqscan;
--test GUC --test GUC
set default_text_search_config=simple; SET default_text_search_config=simple;
select to_tsvector('SKIES My booKs'); SELECT to_tsvector('SKIES My booKs');
to_tsvector to_tsvector
---------------------------- ----------------------------
'my':2 'books':3 'skies':1 'my':2 'books':3 'skies':1
(1 row) (1 row)
select plainto_tsquery('SKIES My booKs'); SELECT plainto_tsquery('SKIES My booKs');
plainto_tsquery plainto_tsquery
-------------------------- --------------------------
'skies' & 'my' & 'books' 'skies' & 'my' & 'books'
(1 row) (1 row)
select to_tsquery('SKIES & My | booKs'); SELECT to_tsquery('SKIES & My | booKs');
to_tsquery to_tsquery
-------------------------- --------------------------
'skies' & 'my' | 'books' 'skies' & 'my' | 'books'
(1 row) (1 row)
set default_text_search_config=english; SET default_text_search_config=english;
select to_tsvector('SKIES My booKs'); SELECT to_tsvector('SKIES My booKs');
to_tsvector to_tsvector
------------------ ------------------
'sky':1 'book':3 'sky':1 'book':3
(1 row) (1 row)
select plainto_tsquery('SKIES My booKs'); SELECT plainto_tsquery('SKIES My booKs');
plainto_tsquery plainto_tsquery
----------------- -----------------
'sky' & 'book' 'sky' & 'book'
(1 row) (1 row)
select to_tsquery('SKIES & My | booKs'); SELECT to_tsquery('SKIES & My | booKs');
to_tsquery to_tsquery
---------------- ----------------
'sky' | 'book' 'sky' | 'book'
@ -884,8 +884,8 @@ SELECT count(*) FROM test_tsvector WHERE a @@ to_tsquery('345&qwerty');
0 0
(1 row) (1 row)
insert into test_tsvector (t) values ('345 qwerty'); INSERT INTO test_tsvector (t) VALUES ('345 qwerty');
select count(*) FROM test_tsvector WHERE a @@ to_tsquery('345&qwerty'); SELECT count(*) FROM test_tsvector WHERE a @@ to_tsquery('345&qwerty');
count count
------- -------
1 1

View File

@ -59,25 +59,25 @@ SELECT E'''1 \\''2'' '' 3'' 4 '::tsvector;
'4' ' 3' '1 ''2' '4' ' 3' '1 ''2'
(1 row) (1 row)
select '''w'':4A,3B,2C,1D,5 a:8'; SELECT '''w'':4A,3B,2C,1D,5 a:8';
?column? ?column?
----------------------- -----------------------
'w':4A,3B,2C,1D,5 a:8 'w':4A,3B,2C,1D,5 a:8
(1 row) (1 row)
select 'a:3A b:2a'::tsvector || 'ba:1234 a:1B'; SELECT 'a:3A b:2a'::tsvector || 'ba:1234 a:1B';
?column? ?column?
---------------------------- ----------------------------
'a':3A,4B 'b':2A 'ba':1237 'a':3A,4B 'b':2A 'ba':1237
(1 row) (1 row)
select setweight('w:12B w:13* w:12,5,6 a:1,3* a:3 w asd:1dc asd zxc:81,567,222A'::tsvector, 'c'); SELECT setweight('w:12B w:13* w:12,5,6 a:1,3* a:3 w asd:1dc asd zxc:81,567,222A'::tsvector, 'c');
setweight setweight
---------------------------------------------------------- ----------------------------------------------------------
'a':1C,3C 'w':5C,6C,12C,13C 'asd':1C 'zxc':81C,222C,567C 'a':1C,3C 'w':5C,6C,12C,13C 'asd':1C 'zxc':81C,222C,567C
(1 row) (1 row)
select strip('w:12B w:13* w:12,5,6 a:1,3* a:3 w asd:1dc asd'::tsvector); SELECT strip('w:12B w:13* w:12,5,6 a:1,3* a:3 w asd:1dc asd'::tsvector);
strip strip
--------------- ---------------
'a' 'w' 'asd' 'a' 'w' 'asd'
@ -318,176 +318,176 @@ SELECT E'1&(''2''&('' 4''&(\\|5 | ''6 \\'' !|&'')))'::tsquery;
'1' & '2' & ' 4' & ( '|5' | '6 '' !|&' ) '1' & '2' & ' 4' & ( '|5' | '6 '' !|&' )
(1 row) (1 row)
select 'a' < 'b & c'::tsquery as "true"; SELECT 'a' < 'b & c'::tsquery as "true";
true true
------ ------
t t
(1 row) (1 row)
select 'a' > 'b & c'::tsquery as "false"; SELECT 'a' > 'b & c'::tsquery as "false";
false false
------- -------
f f
(1 row) (1 row)
select 'a | f' < 'b & c'::tsquery as "true"; SELECT 'a | f' < 'b & c'::tsquery as "true";
true true
------ ------
t t
(1 row) (1 row)
select 'a | ff' < 'b & c'::tsquery as "false"; SELECT 'a | ff' < 'b & c'::tsquery as "false";
false false
------- -------
f f
(1 row) (1 row)
select 'a | f | g' < 'b & c'::tsquery as "false"; SELECT 'a | f | g' < 'b & c'::tsquery as "false";
false false
------- -------
f f
(1 row) (1 row)
select numnode( 'new'::tsquery ); SELECT numnode( 'new'::tsquery );
numnode numnode
--------- ---------
1 1
(1 row) (1 row)
select numnode( 'new & york'::tsquery ); SELECT numnode( 'new & york'::tsquery );
numnode numnode
--------- ---------
3 3
(1 row) (1 row)
select numnode( 'new & york | qwery'::tsquery ); SELECT numnode( 'new & york | qwery'::tsquery );
numnode numnode
--------- ---------
5 5
(1 row) (1 row)
select 'foo & bar'::tsquery && 'asd'; SELECT 'foo & bar'::tsquery && 'asd';
?column? ?column?
----------------------- -----------------------
'foo' & 'bar' & 'asd' 'foo' & 'bar' & 'asd'
(1 row) (1 row)
select 'foo & bar'::tsquery || 'asd & fg'; SELECT 'foo & bar'::tsquery || 'asd & fg';
?column? ?column?
------------------------------ ------------------------------
'foo' & 'bar' | 'asd' & 'fg' 'foo' & 'bar' | 'asd' & 'fg'
(1 row) (1 row)
select 'foo & bar'::tsquery || !!'asd & fg'::tsquery; SELECT 'foo & bar'::tsquery || !!'asd & fg'::tsquery;
?column? ?column?
----------------------------------- -----------------------------------
'foo' & 'bar' | !( 'asd' & 'fg' ) 'foo' & 'bar' | !( 'asd' & 'fg' )
(1 row) (1 row)
select 'foo & bar'::tsquery && 'asd | fg'; SELECT 'foo & bar'::tsquery && 'asd | fg';
?column? ?column?
---------------------------------- ----------------------------------
'foo' & 'bar' & ( 'asd' | 'fg' ) 'foo' & 'bar' & ( 'asd' | 'fg' )
(1 row) (1 row)
-- tsvector-tsquery operations -- tsvector-tsquery operations
select 'a b:89 ca:23A,64b d:34c'::tsvector @@ 'd:AC & ca' as "true"; SELECT 'a b:89 ca:23A,64b d:34c'::tsvector @@ 'd:AC & ca' as "true";
true true
------ ------
t t
(1 row) (1 row)
select 'a b:89 ca:23A,64b d:34c'::tsvector @@ 'd:AC & ca:B' as "true"; SELECT 'a b:89 ca:23A,64b d:34c'::tsvector @@ 'd:AC & ca:B' as "true";
true true
------ ------
t t
(1 row) (1 row)
select 'a b:89 ca:23A,64b d:34c'::tsvector @@ 'd:AC & ca:A' as "true"; SELECT 'a b:89 ca:23A,64b d:34c'::tsvector @@ 'd:AC & ca:A' as "true";
true true
------ ------
t t
(1 row) (1 row)
select 'a b:89 ca:23A,64b d:34c'::tsvector @@ 'd:AC & ca:C' as "false"; SELECT 'a b:89 ca:23A,64b d:34c'::tsvector @@ 'd:AC & ca:C' as "false";
false false
------- -------
f f
(1 row) (1 row)
select 'a b:89 ca:23A,64b d:34c'::tsvector @@ 'd:AC & ca:CB' as "true"; SELECT 'a b:89 ca:23A,64b d:34c'::tsvector @@ 'd:AC & ca:CB' as "true";
true true
------ ------
t t
(1 row) (1 row)
select ts_rank(' a:1 s:2C d g'::tsvector, 'a | s'); SELECT ts_rank(' a:1 s:2C d g'::tsvector, 'a | s');
ts_rank ts_rank
----------- -----------
0.0911891 0.0911891
(1 row) (1 row)
select ts_rank(' a:1 s:2B d g'::tsvector, 'a | s'); SELECT ts_rank(' a:1 s:2B d g'::tsvector, 'a | s');
ts_rank ts_rank
---------- ----------
0.151982 0.151982
(1 row) (1 row)
select ts_rank(' a:1 s:2 d g'::tsvector, 'a | s'); SELECT ts_rank(' a:1 s:2 d g'::tsvector, 'a | s');
ts_rank ts_rank
----------- -----------
0.0607927 0.0607927
(1 row) (1 row)
select ts_rank(' a:1 s:2C d g'::tsvector, 'a & s'); SELECT ts_rank(' a:1 s:2C d g'::tsvector, 'a & s');
ts_rank ts_rank
---------- ----------
0.140153 0.140153
(1 row) (1 row)
select ts_rank(' a:1 s:2B d g'::tsvector, 'a & s'); SELECT ts_rank(' a:1 s:2B d g'::tsvector, 'a & s');
ts_rank ts_rank
---------- ----------
0.198206 0.198206
(1 row) (1 row)
select ts_rank(' a:1 s:2 d g'::tsvector, 'a & s'); SELECT ts_rank(' a:1 s:2 d g'::tsvector, 'a & s');
ts_rank ts_rank
----------- -----------
0.0991032 0.0991032
(1 row) (1 row)
select ts_rank_cd(' a:1 s:2C d g'::tsvector, 'a | s'); SELECT ts_rank_cd(' a:1 s:2C d g'::tsvector, 'a | s');
ts_rank_cd ts_rank_cd
------------ ------------
0.3 0.3
(1 row) (1 row)
select ts_rank_cd(' a:1 s:2B d g'::tsvector, 'a | s'); SELECT ts_rank_cd(' a:1 s:2B d g'::tsvector, 'a | s');
ts_rank_cd ts_rank_cd
------------ ------------
0.5 0.5
(1 row) (1 row)
select ts_rank_cd(' a:1 s:2 d g'::tsvector, 'a | s'); SELECT ts_rank_cd(' a:1 s:2 d g'::tsvector, 'a | s');
ts_rank_cd ts_rank_cd
------------ ------------
0.2 0.2
(1 row) (1 row)
select ts_rank_cd(' a:1 s:2C d g'::tsvector, 'a & s'); SELECT ts_rank_cd(' a:1 s:2C d g'::tsvector, 'a & s');
ts_rank_cd ts_rank_cd
------------ ------------
0.133333 0.133333
(1 row) (1 row)
select ts_rank_cd(' a:1 s:2B d g'::tsvector, 'a & s'); SELECT ts_rank_cd(' a:1 s:2B d g'::tsvector, 'a & s');
ts_rank_cd ts_rank_cd
------------ ------------
0.16 0.16
(1 row) (1 row)
select ts_rank_cd(' a:1 s:2 d g'::tsvector, 'a & s'); SELECT ts_rank_cd(' a:1 s:2 d g'::tsvector, 'a & s');
ts_rank_cd ts_rank_cd
------------ ------------
0.1 0.1

View File

@ -61,9 +61,9 @@ SELECT count(*) FROM test_tsvector WHERE a @@ '(eq|yt)&(wr|qh)';
RESET enable_seqscan; RESET enable_seqscan;
drop index wowidx; DROP INDEX wowidx;
create index wowidx on test_tsvector using gin (a); CREATE INDEX wowidx ON test_tsvector USING gin (a);
SET enable_seqscan=OFF; SET enable_seqscan=OFF;
@ -75,46 +75,46 @@ SELECT count(*) FROM test_tsvector WHERE a @@ '(eq&yt)|(wr&qh)';
SELECT count(*) FROM test_tsvector WHERE a @@ '(eq|yt)&(wr|qh)'; SELECT count(*) FROM test_tsvector WHERE a @@ '(eq|yt)&(wr|qh)';
RESET enable_seqscan; RESET enable_seqscan;
insert into test_tsvector values ('???', 'DFG:1A,2B,6C,10 FGH'); INSERT INTO test_tsvector VALUES ('???', 'DFG:1A,2B,6C,10 FGH');
select * from ts_stat('select a from test_tsvector') order by ndoc desc, nentry desc, word limit 10; SELECT * FROM ts_stat('SELECT a FROM test_tsvector') ORDER BY ndoc DESC, nentry DESC, word LIMIT 10;
select * from ts_stat('select a from test_tsvector', 'AB') order by ndoc desc, nentry desc, word; SELECT * FROM ts_stat('SELECT a FROM test_tsvector', 'AB') ORDER BY ndoc DESC, nentry DESC, word;
--dictionaries and to_tsvector --dictionaries and to_tsvector
select ts_lexize('english', 'skies'); SELECT ts_lexize('english', 'skies');
select ts_lexize('english', 'identity'); SELECT ts_lexize('english', 'identity');
select * from ts_token_type('default'); SELECT * FROM ts_token_type('default');
select * from ts_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>"> SELECT * FROM ts_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 /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'); <i <b> wow < jqw <> qwerty');
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>"> 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 /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'); <i <b> wow < jqw <> qwerty');
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>"> 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 /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')); <i <b> wow < jqw <> qwerty'));
-- to_tsquery -- to_tsquery
select to_tsquery('english', 'qwe & sKies '); SELECT to_tsquery('english', 'qwe & sKies ');
select to_tsquery('simple', 'qwe & sKies '); SELECT to_tsquery('simple', 'qwe & sKies ');
select to_tsquery('english', '''the wether'':dc & '' sKies '':BC '); 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', '(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 to_tsquery('english', '(the|and&(i&1))&fghj');
select plainto_tsquery('english', 'the and z 1))& fghj'); 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');
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') || !!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 plainto_tsquery('english', 'foo bar') && 'asd | fg';
select ts_rank_cd(to_tsvector('english', 'Erosion It took the sea a thousand years, SELECT ts_rank_cd(to_tsvector('english', 'Erosion It took the sea a thousand years,
A thousand years to trace A thousand years to trace
The granite features of this cliff The granite features of this cliff
In crag and scarp and base. In crag and scarp and base.
@ -124,7 +124,7 @@ The sculpture of these granite seams,
Upon a woman s face. E. J. Pratt (1882 1964) Upon a woman s face. E. J. Pratt (1882 1964)
'), to_tsquery('english', 'sea&thousand&years')); '), to_tsquery('english', 'sea&thousand&years'));
select ts_rank_cd(to_tsvector('english', 'Erosion It took the sea a thousand years, SELECT ts_rank_cd(to_tsvector('english', 'Erosion It took the sea a thousand years,
A thousand years to trace A thousand years to trace
The granite features of this cliff The granite features of this cliff
In crag and scarp and base. In crag and scarp and base.
@ -134,7 +134,7 @@ The sculpture of these granite seams,
Upon a woman s face. E. J. Pratt (1882 1964) Upon a woman s face. E. J. Pratt (1882 1964)
'), to_tsquery('english', 'granite&sea')); '), to_tsquery('english', 'granite&sea'));
select ts_rank_cd(to_tsvector('english', 'Erosion It took the sea a thousand years, SELECT ts_rank_cd(to_tsvector('english', 'Erosion It took the sea a thousand years,
A thousand years to trace A thousand years to trace
The granite features of this cliff The granite features of this cliff
In crag and scarp and base. In crag and scarp and base.
@ -145,7 +145,7 @@ Upon a woman s face. E. J. Pratt (1882 1964)
'), to_tsquery('english', 'sea')); '), to_tsquery('english', 'sea'));
--headline tests --headline tests
select ts_headline('english', 'Erosion It took the sea a thousand years, SELECT ts_headline('english', 'Erosion It took the sea a thousand years,
A thousand years to trace A thousand years to trace
The granite features of this cliff The granite features of this cliff
In crag and scarp and base. In crag and scarp and base.
@ -155,7 +155,7 @@ The sculpture of these granite seams,
Upon a woman s face. E. J. Pratt (1882 1964) Upon a woman s face. E. J. Pratt (1882 1964)
', to_tsquery('english', 'sea&thousand&years')); ', to_tsquery('english', 'sea&thousand&years'));
select ts_headline('english', 'Erosion It took the sea a thousand years, SELECT ts_headline('english', 'Erosion It took the sea a thousand years,
A thousand years to trace A thousand years to trace
The granite features of this cliff The granite features of this cliff
In crag and scarp and base. In crag and scarp and base.
@ -165,7 +165,7 @@ The sculpture of these granite seams,
Upon a woman s face. E. J. Pratt (1882 1964) Upon a woman s face. E. J. Pratt (1882 1964)
', to_tsquery('english', 'granite&sea')); ', to_tsquery('english', 'granite&sea'));
select ts_headline('english', 'Erosion It took the sea a thousand years, SELECT ts_headline('english', 'Erosion It took the sea a thousand years,
A thousand years to trace A thousand years to trace
The granite features of this cliff The granite features of this cliff
In crag and scarp and base. In crag and scarp and base.
@ -175,7 +175,7 @@ The sculpture of these granite seams,
Upon a woman s face. E. J. Pratt (1882 1964) Upon a woman s face. E. J. Pratt (1882 1964)
', to_tsquery('english', 'sea')); ', to_tsquery('english', 'sea'));
select ts_headline('english', ' SELECT ts_headline('english', '
<html> <html>
<!-- some comment --> <!-- some comment -->
<body> <body>
@ -191,7 +191,7 @@ to_tsquery('english', 'sea&foo'), 'HighlightAll=true');
--Rewrite sub system --Rewrite sub system
create table test_tsquery (txtkeyword text, txtsample text); CREATE TABLE test_tsquery (txtkeyword TEXT, txtsample TEXT);
\set ECHO none \set ECHO none
\copy test_tsquery from stdin \copy test_tsquery from stdin
'New York' new & york | big & apple | nyc 'New York' new & york | big & apple | nyc
@ -201,80 +201,80 @@ Moscow moskva | moscow
\. \.
\set ECHO all \set ECHO all
alter table test_tsquery add column keyword tsquery; ALTER TABLE test_tsquery ADD COLUMN keyword tsquery;
update test_tsquery set keyword = to_tsquery('english', txtkeyword); UPDATE test_tsquery SET keyword = to_tsquery('english', txtkeyword);
alter table test_tsquery add column sample tsquery; ALTER TABLE test_tsquery ADD COLUMN sample tsquery;
update test_tsquery set sample = to_tsquery('english', txtsample::text); UPDATE test_tsquery SET sample = to_tsquery('english', txtsample::text);
select count(*) from test_tsquery where keyword < 'new & york'; SELECT COUNT(*) FROM test_tsquery WHERE keyword < 'new & york';
select count(*) from test_tsquery where keyword <= 'new & york'; SELECT COUNT(*) FROM test_tsquery WHERE keyword <= 'new & york';
select count(*) from test_tsquery where keyword = 'new & york'; SELECT COUNT(*) FROM test_tsquery WHERE keyword = 'new & york';
select count(*) from test_tsquery where keyword >= 'new & york'; SELECT COUNT(*) FROM test_tsquery WHERE keyword >= 'new & york';
select count(*) from test_tsquery where keyword > 'new & york'; SELECT COUNT(*) FROM test_tsquery WHERE keyword > 'new & york';
create unique index bt_tsq on test_tsquery (keyword); CREATE UNIQUE INDEX bt_tsq ON test_tsquery (keyword);
SET enable_seqscan=OFF; SET enable_seqscan=OFF;
select count(*) from test_tsquery where keyword < 'new & york'; SELECT COUNT(*) FROM test_tsquery WHERE keyword < 'new & york';
select count(*) from test_tsquery where keyword <= 'new & york'; SELECT COUNT(*) FROM test_tsquery WHERE keyword <= 'new & york';
select count(*) from test_tsquery where keyword = 'new & york'; SELECT COUNT(*) FROM test_tsquery WHERE keyword = 'new & york';
select count(*) from test_tsquery where keyword >= 'new & york'; SELECT COUNT(*) FROM test_tsquery WHERE keyword >= 'new & york';
select count(*) from test_tsquery where keyword > 'new & york'; SELECT COUNT(*) FROM test_tsquery WHERE keyword > 'new & york';
RESET enable_seqscan; RESET enable_seqscan;
select ts_rewrite('foo & bar & qq & new & york', 'new & york'::tsquery, 'big & apple | nyc | new & york & city'); SELECT ts_rewrite('foo & bar & qq & new & york', 'new & york'::tsquery, 'big & apple | nyc | new & york & city');
select ts_rewrite('moscow', 'select keyword, sample from test_tsquery'::text ); SELECT ts_rewrite('moscow', 'SELECT keyword, sample FROM test_tsquery'::text );
select ts_rewrite('moscow & hotel', 'select keyword, sample from test_tsquery'::text ); SELECT ts_rewrite('moscow & hotel', 'SELECT keyword, sample FROM test_tsquery'::text );
select ts_rewrite('bar & new & qq & foo & york', 'select keyword, sample from test_tsquery'::text ); SELECT ts_rewrite('bar & new & qq & foo & york', 'SELECT keyword, sample FROM test_tsquery'::text );
select ts_rewrite( ARRAY['moscow', keyword, sample] ) from test_tsquery; SELECT ts_rewrite( ARRAY['moscow', keyword, sample] ) FROM test_tsquery;
select ts_rewrite( ARRAY['moscow & hotel', keyword, sample] ) from test_tsquery; SELECT ts_rewrite( ARRAY['moscow & hotel', keyword, sample] ) FROM test_tsquery;
select ts_rewrite( ARRAY['bar & new & qq & foo & york', keyword, sample] ) from test_tsquery; SELECT ts_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 @> 'new';
select keyword from test_tsquery where keyword @> 'moscow'; SELECT keyword FROM test_tsquery WHERE keyword @> 'moscow';
select keyword from test_tsquery where keyword <@ 'new'; SELECT keyword FROM test_tsquery WHERE keyword <@ 'new';
select keyword from test_tsquery where keyword <@ 'moscow'; SELECT keyword FROM test_tsquery WHERE keyword <@ 'moscow';
select ts_rewrite( ARRAY[query, keyword, sample] ) from test_tsquery, to_tsquery('english', 'moscow') as query where keyword <@ query; SELECT ts_rewrite( ARRAY[query, keyword, sample] ) FROM test_tsquery, to_tsquery('english', 'moscow') AS query WHERE keyword <@ query;
select ts_rewrite( ARRAY[query, keyword, sample] ) from test_tsquery, to_tsquery('english', 'moscow & hotel') as query where keyword <@ query; SELECT ts_rewrite( ARRAY[query, keyword, sample] ) FROM test_tsquery, to_tsquery('english', 'moscow & hotel') AS query WHERE keyword <@ query;
select ts_rewrite( ARRAY[query, keyword, sample] ) from test_tsquery, to_tsquery('english', 'bar & new & qq & foo & york') as query where keyword <@ query; SELECT ts_rewrite( ARRAY[query, keyword, sample] ) FROM test_tsquery, to_tsquery('english', 'bar & new & qq & foo & york') AS query WHERE keyword <@ query;
select ts_rewrite( ARRAY[query, keyword, sample] ) from test_tsquery, to_tsquery('english', 'moscow') as query where query @> keyword; SELECT ts_rewrite( ARRAY[query, keyword, sample] ) FROM test_tsquery, to_tsquery('english', 'moscow') AS query WHERE query @> keyword;
select ts_rewrite( ARRAY[query, keyword, sample] ) from test_tsquery, to_tsquery('english', 'moscow & hotel') as query where query @> keyword; SELECT ts_rewrite( ARRAY[query, keyword, sample] ) FROM test_tsquery, to_tsquery('english', 'moscow & hotel') AS query WHERE query @> keyword;
select ts_rewrite( ARRAY[query, keyword, sample] ) from test_tsquery, to_tsquery('english', 'bar & new & qq & foo & york') as query where query @> keyword; SELECT ts_rewrite( ARRAY[query, keyword, sample] ) FROM test_tsquery, to_tsquery('english', 'bar & new & qq & foo & york') AS query WHERE query @> keyword;
create index qq on test_tsquery using gist (keyword tsquery_ops); CREATE INDEX qq ON test_tsquery USING gist (keyword tsquery_ops);
SET enable_seqscan=OFF; SET enable_seqscan=OFF;
select keyword from test_tsquery where keyword @> 'new'; SELECT keyword FROM test_tsquery WHERE keyword @> 'new';
select keyword from test_tsquery where keyword @> 'moscow'; SELECT keyword FROM test_tsquery WHERE keyword @> 'moscow';
select keyword from test_tsquery where keyword <@ 'new'; SELECT keyword FROM test_tsquery WHERE keyword <@ 'new';
select keyword from test_tsquery where keyword <@ 'moscow'; SELECT keyword FROM test_tsquery WHERE keyword <@ 'moscow';
select ts_rewrite( ARRAY[query, keyword, sample] ) from test_tsquery, to_tsquery('english', 'moscow') as query where keyword <@ query; SELECT ts_rewrite( ARRAY[query, keyword, sample] ) FROM test_tsquery, to_tsquery('english', 'moscow') AS query WHERE keyword <@ query;
select ts_rewrite( ARRAY[query, keyword, sample] ) from test_tsquery, to_tsquery('english', 'moscow & hotel') as query where keyword <@ query; SELECT ts_rewrite( ARRAY[query, keyword, sample] ) FROM test_tsquery, to_tsquery('english', 'moscow & hotel') AS query WHERE keyword <@ query;
select ts_rewrite( ARRAY[query, keyword, sample] ) from test_tsquery, to_tsquery('english', 'bar & new & qq & foo & york') as query where keyword <@ query; SELECT ts_rewrite( ARRAY[query, keyword, sample] ) FROM test_tsquery, to_tsquery('english', 'bar & new & qq & foo & york') AS query WHERE keyword <@ query;
select ts_rewrite( ARRAY[query, keyword, sample] ) from test_tsquery, to_tsquery('english', 'moscow') as query where query @> keyword; SELECT ts_rewrite( ARRAY[query, keyword, sample] ) FROM test_tsquery, to_tsquery('english', 'moscow') AS query WHERE query @> keyword;
select ts_rewrite( ARRAY[query, keyword, sample] ) from test_tsquery, to_tsquery('english', 'moscow & hotel') as query where query @> keyword; SELECT ts_rewrite( ARRAY[query, keyword, sample] ) FROM test_tsquery, to_tsquery('english', 'moscow & hotel') AS query WHERE query @> keyword;
select ts_rewrite( ARRAY[query, keyword, sample] ) from test_tsquery, to_tsquery('english', 'bar & new & qq & foo & york') as query where query @> keyword; SELECT ts_rewrite( ARRAY[query, keyword, sample] ) FROM test_tsquery, to_tsquery('english', 'bar & new & qq & foo & york') AS query WHERE query @> keyword;
RESET enable_seqscan; RESET enable_seqscan;
--test GUC --test GUC
set default_text_search_config=simple; SET default_text_search_config=simple;
select to_tsvector('SKIES My booKs'); SELECT to_tsvector('SKIES My booKs');
select plainto_tsquery('SKIES My booKs'); SELECT plainto_tsquery('SKIES My booKs');
select to_tsquery('SKIES & My | booKs'); SELECT to_tsquery('SKIES & My | booKs');
set default_text_search_config=english; SET default_text_search_config=english;
select to_tsvector('SKIES My booKs'); SELECT to_tsvector('SKIES My booKs');
select plainto_tsquery('SKIES My booKs'); SELECT plainto_tsquery('SKIES My booKs');
select to_tsquery('SKIES & My | booKs'); SELECT to_tsquery('SKIES & My | booKs');
--trigger --trigger
CREATE TRIGGER tsvectorupdate CREATE TRIGGER tsvectorupdate
@ -287,6 +287,6 @@ SELECT count(*) FROM test_tsvector WHERE a @@ to_tsquery('345&qwerty');
UPDATE test_tsvector SET t = null WHERE t = '345 qwerty'; UPDATE test_tsvector SET t = null WHERE t = '345 qwerty';
SELECT count(*) FROM test_tsvector WHERE a @@ to_tsquery('345&qwerty'); SELECT count(*) FROM test_tsvector WHERE a @@ to_tsquery('345&qwerty');
insert into test_tsvector (t) values ('345 qwerty'); INSERT INTO test_tsvector (t) VALUES ('345 qwerty');
select count(*) FROM test_tsvector WHERE a @@ to_tsquery('345&qwerty'); SELECT count(*) FROM test_tsvector WHERE a @@ to_tsquery('345&qwerty');

View File

@ -10,10 +10,10 @@ SELECT E'''1 \\''2'''::tsvector;
SELECT E'''1 \\''2''3'::tsvector; SELECT E'''1 \\''2''3'::tsvector;
SELECT E'''1 \\''2'' 3'::tsvector; SELECT E'''1 \\''2'' 3'::tsvector;
SELECT E'''1 \\''2'' '' 3'' 4 '::tsvector; SELECT E'''1 \\''2'' '' 3'' 4 '::tsvector;
select '''w'':4A,3B,2C,1D,5 a:8'; SELECT '''w'':4A,3B,2C,1D,5 a:8';
select 'a:3A b:2a'::tsvector || 'ba:1234 a:1B'; SELECT 'a:3A b:2a'::tsvector || 'ba:1234 a:1B';
select setweight('w:12B w:13* w:12,5,6 a:1,3* a:3 w asd:1dc asd zxc:81,567,222A'::tsvector, 'c'); SELECT setweight('w:12B w:13* w:12,5,6 a:1,3* a:3 w asd:1dc asd zxc:81,567,222A'::tsvector, 'c');
select strip('w:12B w:13* w:12,5,6 a:1,3* a:3 w asd:1dc asd'::tsvector); SELECT strip('w:12B w:13* w:12,5,6 a:1,3* a:3 w asd:1dc asd'::tsvector);
--Base tsquery test --Base tsquery test
SELECT '1'::tsquery; SELECT '1'::tsquery;
@ -56,40 +56,39 @@ SELECT '1&(2&(4&(5|6)))'::tsquery;
SELECT '1&(2&(4&(5|!6)))'::tsquery; SELECT '1&(2&(4&(5|!6)))'::tsquery;
SELECT E'1&(''2''&('' 4''&(\\|5 | ''6 \\'' !|&'')))'::tsquery; SELECT E'1&(''2''&('' 4''&(\\|5 | ''6 \\'' !|&'')))'::tsquery;
select 'a' < 'b & c'::tsquery as "true"; SELECT 'a' < 'b & c'::tsquery as "true";
select 'a' > 'b & c'::tsquery as "false"; SELECT 'a' > 'b & c'::tsquery as "false";
select 'a | f' < 'b & c'::tsquery as "true"; SELECT 'a | f' < 'b & c'::tsquery as "true";
select 'a | ff' < 'b & c'::tsquery as "false"; SELECT 'a | ff' < 'b & c'::tsquery as "false";
select 'a | f | g' < 'b & c'::tsquery as "false"; SELECT 'a | f | g' < 'b & c'::tsquery as "false";
select numnode( 'new'::tsquery ); SELECT numnode( 'new'::tsquery );
select numnode( 'new & york'::tsquery ); SELECT numnode( 'new & york'::tsquery );
select numnode( 'new & york | qwery'::tsquery ); SELECT numnode( 'new & york | qwery'::tsquery );
select 'foo & bar'::tsquery && 'asd'; SELECT 'foo & bar'::tsquery && 'asd';
select 'foo & bar'::tsquery || 'asd & fg'; SELECT 'foo & bar'::tsquery || 'asd & fg';
select 'foo & bar'::tsquery || !!'asd & fg'::tsquery; SELECT 'foo & bar'::tsquery || !!'asd & fg'::tsquery;
select 'foo & bar'::tsquery && 'asd | fg'; SELECT 'foo & bar'::tsquery && 'asd | fg';
-- tsvector-tsquery operations -- tsvector-tsquery operations
select 'a b:89 ca:23A,64b d:34c'::tsvector @@ 'd:AC & ca' as "true"; SELECT 'a b:89 ca:23A,64b d:34c'::tsvector @@ 'd:AC & ca' as "true";
select 'a b:89 ca:23A,64b d:34c'::tsvector @@ 'd:AC & ca:B' as "true"; SELECT 'a b:89 ca:23A,64b d:34c'::tsvector @@ 'd:AC & ca:B' as "true";
select 'a b:89 ca:23A,64b d:34c'::tsvector @@ 'd:AC & ca:A' as "true"; SELECT 'a b:89 ca:23A,64b d:34c'::tsvector @@ 'd:AC & ca:A' as "true";
select 'a b:89 ca:23A,64b d:34c'::tsvector @@ 'd:AC & ca:C' as "false"; SELECT 'a b:89 ca:23A,64b d:34c'::tsvector @@ 'd:AC & ca:C' as "false";
select 'a b:89 ca:23A,64b d:34c'::tsvector @@ 'd:AC & ca:CB' as "true"; SELECT 'a b:89 ca:23A,64b d:34c'::tsvector @@ 'd:AC & ca:CB' as "true";
select ts_rank(' a:1 s:2C d g'::tsvector, 'a | s'); SELECT ts_rank(' a:1 s:2C d g'::tsvector, 'a | s');
select ts_rank(' a:1 s:2B d g'::tsvector, 'a | s'); SELECT ts_rank(' a:1 s:2B d g'::tsvector, 'a | s');
select ts_rank(' a:1 s:2 d g'::tsvector, 'a | s'); SELECT ts_rank(' a:1 s:2 d g'::tsvector, 'a | s');
select ts_rank(' a:1 s:2C d g'::tsvector, 'a & s'); SELECT ts_rank(' a:1 s:2C d g'::tsvector, 'a & s');
select ts_rank(' a:1 s:2B d g'::tsvector, 'a & s'); SELECT ts_rank(' a:1 s:2B d g'::tsvector, 'a & s');
select ts_rank(' a:1 s:2 d g'::tsvector, 'a & s'); SELECT ts_rank(' a:1 s:2 d g'::tsvector, 'a & s');
select ts_rank_cd(' a:1 s:2C d g'::tsvector, 'a | s');
select ts_rank_cd(' a:1 s:2B d g'::tsvector, 'a | s');
select ts_rank_cd(' a:1 s:2 d g'::tsvector, 'a | s');
select ts_rank_cd(' a:1 s:2C d g'::tsvector, 'a & s');
select ts_rank_cd(' a:1 s:2B d g'::tsvector, 'a & s');
select ts_rank_cd(' a:1 s:2 d g'::tsvector, 'a & s');
SELECT ts_rank_cd(' a:1 s:2C d g'::tsvector, 'a | s');
SELECT ts_rank_cd(' a:1 s:2B d g'::tsvector, 'a | s');
SELECT ts_rank_cd(' a:1 s:2 d g'::tsvector, 'a | s');
SELECT ts_rank_cd(' a:1 s:2C d g'::tsvector, 'a & s');
SELECT ts_rank_cd(' a:1 s:2B d g'::tsvector, 'a & s');
SELECT ts_rank_cd(' a:1 s:2 d g'::tsvector, 'a & s');