(1 row)
RESET enable_seqscan;
-drop index wowidx;
-create index wowidx on test_tsvector using gin (a);
+DROP INDEX wowidx;
+CREATE INDEX wowidx ON test_tsvector USING gin (a);
SET enable_seqscan=OFF;
SELECT count(*) FROM test_tsvector WHERE a @@ 'wr|qh';
count
RESET enable_seqscan;
-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;
+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;
word | ndoc | nentry
------+------+--------
qq | 108 | 108
qr | 92 | 92
(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
------+------+--------
DFG | 1 | 2
(1 row)
--dictionaries and to_tsvector
-select ts_lexize('english', 'skies');
+SELECT ts_lexize('english', 'skies');
ts_lexize
-----------
{sky}
(1 row)
-select ts_lexize('english', 'identity');
+SELECT ts_lexize('english', 'identity');
ts_lexize
-----------
{ident}
(1 row)
-select * from ts_token_type('default');
+SELECT * FROM ts_token_type('default');
tokid | alias | description
-------+--------------+-----------------------------------
1 | lword | Latin word
23 | entity | HTML Entity
(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
<i <b> wow < jqw <> qwerty');
tokid | token
1 | qwerty
(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
<i <b> wow < jqw <> qwerty');
to_tsvector
'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)
-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
<i <b> wow < jqw <> qwerty'));
length
(1 row)
-- to_tsquery
-select to_tsquery('english', 'qwe & sKies ');
+SELECT to_tsquery('english', 'qwe & sKies ');
to_tsquery
---------------
'qwe' & 'sky'
(1 row)
-select to_tsquery('simple', 'qwe & sKies ');
+SELECT to_tsquery('simple', 'qwe & sKies ');
to_tsquery
-----------------
'qwe' & 'skies'
(1 row)
-select to_tsquery('english', '''the wether'':dc & '' sKies '':BC ');
+SELECT to_tsquery('english', '''the wether'':dc & '' sKies '':BC ');
to_tsquery
------------------------
'wether':CD & 'sky':BC
(1 row)
-select to_tsquery('english', 'asd&(and|fghj)');
+SELECT to_tsquery('english', 'asd&(and|fghj)');
to_tsquery
----------------
'asd' & 'fghj'
(1 row)
-select to_tsquery('english', '(asd&and)|fghj');
+SELECT to_tsquery('english', '(asd&and)|fghj');
to_tsquery
----------------
'asd' | 'fghj'
(1 row)
-select to_tsquery('english', '(asd&!and)|fghj');
+SELECT to_tsquery('english', '(asd&!and)|fghj');
to_tsquery
----------------
'asd' | 'fghj'
(1 row)
-select to_tsquery('english', '(the|and&(i&1))&fghj');
+SELECT to_tsquery('english', '(the|and&(i&1))&fghj');
to_tsquery
--------------
'1' & 'fghj'
(1 row)
-select plainto_tsquery('english', 'the and z 1))& fghj');
+SELECT plainto_tsquery('english', 'the and z 1))& fghj');
plainto_tsquery
--------------------
'z' & '1' & 'fghj'
(1 row)
-select plainto_tsquery('english', 'foo bar') && plainto_tsquery('english', 'asd');
+SELECT plainto_tsquery('english', 'foo bar') && plainto_tsquery('english', 'asd');
?column?
-----------------------
'foo' & 'bar' & 'asd'
(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?
------------------------------
'foo' & 'bar' | 'asd' & 'fg'
(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?
-----------------------------------
'foo' & 'bar' | !( 'asd' & 'fg' )
(1 row)
-select plainto_tsquery('english', 'foo bar') && 'asd | fg';
+SELECT plainto_tsquery('english', 'foo bar') && 'asd | fg';
?column?
----------------------------------
'foo' & 'bar' & ( 'asd' | 'fg' )
(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
The granite features of this cliff
In crag and scarp and base.
0.0555556
(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
The granite features of this cliff
In crag and scarp and base.
0.0238095
(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
The granite features of this cliff
In crag and scarp and base.
(1 row)
--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
The granite features of this cliff
In crag and scarp and base.
The granite features of this cliff
(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
The granite features of this cliff
In crag and scarp and base.
The <b>granite</b> features of this cliff
(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
The granite features of this cliff
In crag and scarp and base.
The granite features of this cliff
(1 row)
-select ts_headline('english', '
+SELECT ts_headline('english', '
<html>
<!-- some comment -->
<body>
(1 row)
--Rewrite sub system
-create table test_tsquery (txtkeyword text, txtsample text);
+CREATE TABLE test_tsquery (txtkeyword TEXT, txtsample TEXT);
\set ECHO none
-alter table test_tsquery add column keyword tsquery;
-update test_tsquery set keyword = to_tsquery('english', txtkeyword);
-alter table test_tsquery add column sample tsquery;
-update test_tsquery set sample = to_tsquery('english', txtsample::text);
-select count(*) from test_tsquery where keyword < 'new & york';
+ALTER TABLE test_tsquery ADD COLUMN keyword tsquery;
+UPDATE test_tsquery SET keyword = to_tsquery('english', txtkeyword);
+ALTER TABLE test_tsquery ADD COLUMN sample tsquery;
+UPDATE test_tsquery SET sample = to_tsquery('english', txtsample::text);
+SELECT COUNT(*) FROM test_tsquery WHERE keyword < 'new & york';
count
-------
1
(1 row)
-select count(*) from test_tsquery where keyword <= 'new & york';
+SELECT COUNT(*) FROM test_tsquery WHERE keyword <= 'new & york';
count
-------
2
(1 row)
-select count(*) from test_tsquery where keyword = 'new & york';
+SELECT COUNT(*) FROM test_tsquery WHERE keyword = 'new & york';
count
-------
1
(1 row)
-select count(*) from test_tsquery where keyword >= 'new & york';
+SELECT COUNT(*) FROM test_tsquery WHERE keyword >= 'new & york';
count
-------
3
(1 row)
-select count(*) from test_tsquery where keyword > 'new & york';
+SELECT COUNT(*) FROM test_tsquery WHERE keyword > 'new & york';
count
-------
2
(1 row)
-create unique index bt_tsq on test_tsquery (keyword);
+CREATE UNIQUE INDEX bt_tsq ON test_tsquery (keyword);
SET enable_seqscan=OFF;
-select count(*) from test_tsquery where keyword < 'new & york';
+SELECT COUNT(*) FROM test_tsquery WHERE keyword < 'new & york';
count
-------
1
(1 row)
-select count(*) from test_tsquery where keyword <= 'new & york';
+SELECT COUNT(*) FROM test_tsquery WHERE keyword <= 'new & york';
count
-------
2
(1 row)
-select count(*) from test_tsquery where keyword = 'new & york';
+SELECT COUNT(*) FROM test_tsquery WHERE keyword = 'new & york';
count
-------
1
(1 row)
-select count(*) from test_tsquery where keyword >= 'new & york';
+SELECT COUNT(*) FROM test_tsquery WHERE keyword >= 'new & york';
count
-------
3
(1 row)
-select count(*) from test_tsquery where keyword > 'new & york';
+SELECT COUNT(*) FROM test_tsquery WHERE keyword > 'new & york';
count
-------
2
(1 row)
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
----------------------------------------------------------------------------------
'foo' & 'bar' & 'qq' & ( 'city' & 'new' & 'york' | ( 'nyc' | 'big' & 'apple' ) )
(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
---------------------
'moskva' | 'moscow'
(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
-----------------------------------
( 'moskva' | 'moscow' ) & 'hotel'
(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
-------------------------------------------------------------------------------------
'citi' & 'foo' & ( 'bar' | 'qq' ) & ( 'nyc' | ( 'big' & 'appl' | 'new' & 'york' ) )
(1 row)
-select ts_rewrite( ARRAY['moscow', keyword, sample] ) from test_tsquery;
+SELECT ts_rewrite( ARRAY['moscow', keyword, sample] ) FROM test_tsquery;
ts_rewrite
---------------------
'moskva' | 'moscow'
(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
-----------------------------------
( 'moskva' | 'moscow' ) & 'hotel'
(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
-------------------------------------------------------------------------------------
'citi' & 'foo' & ( 'bar' | 'qq' ) & ( 'nyc' | ( 'big' & 'appl' | 'new' & 'york' ) )
(1 row)
-select keyword from test_tsquery where keyword @> 'new';
+SELECT keyword FROM test_tsquery WHERE keyword @> 'new';
keyword
----------------
'new' & 'york'
(1 row)
-select keyword from test_tsquery where keyword @> 'moscow';
+SELECT keyword FROM test_tsquery WHERE keyword @> 'moscow';
keyword
----------
'moscow'
(1 row)
-select keyword from test_tsquery where keyword <@ 'new';
+SELECT keyword FROM test_tsquery WHERE keyword <@ 'new';
keyword
---------
(0 rows)
-select keyword from test_tsquery where keyword <@ 'moscow';
+SELECT keyword FROM test_tsquery WHERE keyword <@ 'moscow';
keyword
----------
'moscow'
(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
---------------------
'moskva' | 'moscow'
(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
-----------------------------------
( 'moskva' | 'moscow' ) & 'hotel'
(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
-------------------------------------------------------------------------------------
'citi' & 'foo' & ( 'bar' | 'qq' ) & ( 'nyc' | ( 'big' & 'appl' | 'new' & 'york' ) )
(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
---------------------
'moskva' | 'moscow'
(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
-----------------------------------
( 'moskva' | 'moscow' ) & 'hotel'
(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
-------------------------------------------------------------------------------------
'citi' & 'foo' & ( 'bar' | 'qq' ) & ( 'nyc' | ( 'big' & 'appl' | 'new' & 'york' ) )
(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;
-select keyword from test_tsquery where keyword @> 'new';
+SELECT keyword FROM test_tsquery WHERE keyword @> 'new';
keyword
----------------
'new' & 'york'
(1 row)
-select keyword from test_tsquery where keyword @> 'moscow';
+SELECT keyword FROM test_tsquery WHERE keyword @> 'moscow';
keyword
----------
'moscow'
(1 row)
-select keyword from test_tsquery where keyword <@ 'new';
+SELECT keyword FROM test_tsquery WHERE keyword <@ 'new';
keyword
---------
(0 rows)
-select keyword from test_tsquery where keyword <@ 'moscow';
+SELECT keyword FROM test_tsquery WHERE keyword <@ 'moscow';
keyword
----------
'moscow'
(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
---------------------
'moskva' | 'moscow'
(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
-----------------------------------
( 'moskva' | 'moscow' ) & 'hotel'
(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
-------------------------------------------------------------------------------------
'citi' & 'foo' & ( 'bar' | 'qq' ) & ( 'nyc' | ( 'big' & 'appl' | 'new' & 'york' ) )
(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
---------------------
'moskva' | 'moscow'
(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
-----------------------------------
( 'moskva' | 'moscow' ) & 'hotel'
(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
-------------------------------------------------------------------------------------
'citi' & 'foo' & ( 'bar' | 'qq' ) & ( 'nyc' | ( 'big' & 'appl' | 'new' & 'york' ) )
RESET enable_seqscan;
--test GUC
-set default_text_search_config=simple;
-select to_tsvector('SKIES My booKs');
+SET default_text_search_config=simple;
+SELECT to_tsvector('SKIES My booKs');
to_tsvector
----------------------------
'my':2 'books':3 'skies':1
(1 row)
-select plainto_tsquery('SKIES My booKs');
+SELECT plainto_tsquery('SKIES My booKs');
plainto_tsquery
--------------------------
'skies' & 'my' & 'books'
(1 row)
-select to_tsquery('SKIES & My | booKs');
+SELECT to_tsquery('SKIES & My | booKs');
to_tsquery
--------------------------
'skies' & 'my' | 'books'
(1 row)
-set default_text_search_config=english;
-select to_tsvector('SKIES My booKs');
+SET default_text_search_config=english;
+SELECT to_tsvector('SKIES My booKs');
to_tsvector
------------------
'sky':1 'book':3
(1 row)
-select plainto_tsquery('SKIES My booKs');
+SELECT plainto_tsquery('SKIES My booKs');
plainto_tsquery
-----------------
'sky' & 'book'
(1 row)
-select to_tsquery('SKIES & My | booKs');
+SELECT to_tsquery('SKIES & My | booKs');
to_tsquery
----------------
'sky' | 'book'
0
(1 row)
-insert into test_tsvector (t) values ('345 qwerty');
-select count(*) FROM test_tsvector WHERE a @@ to_tsquery('345&qwerty');
+INSERT INTO test_tsvector (t) VALUES ('345 qwerty');
+SELECT count(*) FROM test_tsvector WHERE a @@ to_tsquery('345&qwerty');
count
-------
1
'4' ' 3' '1 ''2'
(1 row)
-select '''w'':4A,3B,2C,1D,5 a:8';
+SELECT '''w'':4A,3B,2C,1D,5 a:8';
?column?
-----------------------
'w':4A,3B,2C,1D,5 a:8
(1 row)
-select 'a:3A b:2a'::tsvector || 'ba:1234 a:1B';
+SELECT 'a:3A b:2a'::tsvector || 'ba:1234 a:1B';
?column?
----------------------------
'a':3A,4B 'b':2A 'ba':1237
(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
----------------------------------------------------------
'a':1C,3C 'w':5C,6C,12C,13C 'asd':1C 'zxc':81C,222C,567C
(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
---------------
'a' 'w' 'asd'
'1' & '2' & ' 4' & ( '|5' | '6 '' !|&' )
(1 row)
-select 'a' < 'b & c'::tsquery as "true";
+SELECT 'a' < 'b & c'::tsquery as "true";
true
------
t
(1 row)
-select 'a' > 'b & c'::tsquery as "false";
+SELECT 'a' > 'b & c'::tsquery as "false";
false
-------
f
(1 row)
-select 'a | f' < 'b & c'::tsquery as "true";
+SELECT 'a | f' < 'b & c'::tsquery as "true";
true
------
t
(1 row)
-select 'a | ff' < 'b & c'::tsquery as "false";
+SELECT 'a | ff' < 'b & c'::tsquery as "false";
false
-------
f
(1 row)
-select 'a | f | g' < 'b & c'::tsquery as "false";
+SELECT 'a | f | g' < 'b & c'::tsquery as "false";
false
-------
f
(1 row)
-select numnode( 'new'::tsquery );
+SELECT numnode( 'new'::tsquery );
numnode
---------
1
(1 row)
-select numnode( 'new & york'::tsquery );
+SELECT numnode( 'new & york'::tsquery );
numnode
---------
3
(1 row)
-select numnode( 'new & york | qwery'::tsquery );
+SELECT numnode( 'new & york | qwery'::tsquery );
numnode
---------
5
(1 row)
-select 'foo & bar'::tsquery && 'asd';
+SELECT 'foo & bar'::tsquery && 'asd';
?column?
-----------------------
'foo' & 'bar' & 'asd'
(1 row)
-select 'foo & bar'::tsquery || 'asd & fg';
+SELECT 'foo & bar'::tsquery || 'asd & fg';
?column?
------------------------------
'foo' & 'bar' | 'asd' & 'fg'
(1 row)
-select 'foo & bar'::tsquery || !!'asd & fg'::tsquery;
+SELECT 'foo & bar'::tsquery || !!'asd & fg'::tsquery;
?column?
-----------------------------------
'foo' & 'bar' | !( 'asd' & 'fg' )
(1 row)
-select 'foo & bar'::tsquery && 'asd | fg';
+SELECT 'foo & bar'::tsquery && 'asd | fg';
?column?
----------------------------------
'foo' & 'bar' & ( 'asd' | 'fg' )
(1 row)
-- 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
------
t
(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
------
t
(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
------
t
(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
-------
f
(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
------
t
(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
-----------
0.0911891
(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
----------
0.151982
(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
-----------
0.0607927
(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
----------
0.140153
(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
----------
0.198206
(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
-----------
0.0991032
(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
------------
0.3
(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
------------
0.5
(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
------------
0.2
(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
------------
0.133333
(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
------------
0.16
(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
------------
0.1
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;
SELECT count(*) FROM test_tsvector WHERE a @@ '(eq|yt)&(wr|qh)';
RESET enable_seqscan;
-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', 'AB') order by ndoc desc, nentry desc, word;
+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', 'AB') ORDER BY ndoc DESC, nentry DESC, word;
--dictionaries and to_tsvector
-select ts_lexize('english', 'skies');
-select ts_lexize('english', 'identity');
+SELECT ts_lexize('english', 'skies');
+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
<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
<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
<i <b> wow < jqw <> qwerty'));
-- to_tsquery
-select to_tsquery('english', 'qwe & sKies ');
-select to_tsquery('simple', 'qwe & sKies ');
-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('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 ts_rank_cd(to_tsvector('english', 'Erosion It took the sea a thousand years,
+SELECT to_tsquery('english', 'qwe & sKies ');
+SELECT to_tsquery('simple', 'qwe & sKies ');
+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('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 ts_rank_cd(to_tsvector('english', '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.
Upon a woman s face. E. J. Pratt (1882 1964)
'), 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
The granite features of this cliff
In crag and scarp and base.
Upon a woman s face. E. J. Pratt (1882 1964)
'), 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
The granite features of this cliff
In crag and scarp and base.
'), to_tsquery('english', 'sea'));
--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
The granite features of this cliff
In crag and scarp and base.
Upon a woman s face. E. J. Pratt (1882 1964)
', 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
The granite features of this cliff
In crag and scarp and base.
Upon a woman s face. E. J. Pratt (1882 1964)
', 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
The granite features of this cliff
In crag and scarp and base.
Upon a woman s face. E. J. Pratt (1882 1964)
', to_tsquery('english', 'sea'));
-select ts_headline('english', '
+SELECT ts_headline('english', '
<html>
<!-- some comment -->
<body>
--Rewrite sub system
-create table test_tsquery (txtkeyword text, txtsample text);
+CREATE TABLE test_tsquery (txtkeyword TEXT, txtsample TEXT);
\set ECHO none
\copy test_tsquery from stdin
'New York' new & york | big & apple | nyc
\.
\set ECHO all
-alter table test_tsquery add column keyword tsquery;
-update test_tsquery set keyword = to_tsquery('english', txtkeyword);
-alter table test_tsquery add column sample tsquery;
-update test_tsquery set sample = to_tsquery('english', txtsample::text);
+ALTER TABLE test_tsquery ADD COLUMN keyword tsquery;
+UPDATE test_tsquery SET keyword = to_tsquery('english', txtkeyword);
+ALTER TABLE test_tsquery ADD COLUMN sample tsquery;
+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;
-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;
-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 & 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('moscow', '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( ARRAY['moscow', 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['moscow', 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 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 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', '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 & 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 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 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', '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 & 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;
-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;
-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 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', '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 & 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 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 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', '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 & 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;
RESET enable_seqscan;
--test GUC
-set default_text_search_config=simple;
+SET default_text_search_config=simple;
-select to_tsvector('SKIES My booKs');
-select plainto_tsquery('SKIES My booKs');
-select to_tsquery('SKIES & My | booKs');
+SELECT to_tsvector('SKIES My booKs');
+SELECT plainto_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 plainto_tsquery('SKIES My booKs');
-select to_tsquery('SKIES & My | booKs');
+SELECT to_tsvector('SKIES My booKs');
+SELECT plainto_tsquery('SKIES My booKs');
+SELECT to_tsquery('SKIES & My | booKs');
--trigger
CREATE TRIGGER tsvectorupdate
UPDATE test_tsvector SET t = null WHERE t = '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');
SELECT E'''1 \\''2''3'::tsvector;
SELECT E'''1 \\''2'' 3'::tsvector;
SELECT E'''1 \\''2'' '' 3'' 4 '::tsvector;
-select '''w'':4A,3B,2C,1D,5 a:8';
-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 strip('w:12B w:13* w:12,5,6 a:1,3* a:3 w asd:1dc asd'::tsvector);
+SELECT '''w'':4A,3B,2C,1D,5 a:8';
+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 strip('w:12B w:13* w:12,5,6 a:1,3* a:3 w asd:1dc asd'::tsvector);
--Base tsquery test
SELECT '1'::tsquery;
SELECT '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 "false";
-select 'a | f' < 'b & c'::tsquery as "true";
-select 'a | ff' < 'b & c'::tsquery as "false";
-select 'a | f | g' < 'b & c'::tsquery as "false";
+SELECT 'a' < 'b & c'::tsquery as "true";
+SELECT 'a' > 'b & c'::tsquery as "false";
+SELECT 'a | f' < 'b & c'::tsquery as "true";
+SELECT 'a | ff' < 'b & c'::tsquery as "false";
+SELECT 'a | f | g' < 'b & c'::tsquery as "false";
-select numnode( 'new'::tsquery );
-select numnode( 'new & york'::tsquery );
-select numnode( 'new & york | qwery'::tsquery );
+SELECT numnode( 'new'::tsquery );
+SELECT numnode( 'new & york'::tsquery );
+SELECT numnode( 'new & york | qwery'::tsquery );
-select 'foo & bar'::tsquery && 'asd';
-select 'foo & bar'::tsquery || 'asd & fg';
-select 'foo & bar'::tsquery || !!'asd & fg'::tsquery;
-select 'foo & bar'::tsquery && 'asd | fg';
+SELECT 'foo & bar'::tsquery && 'asd';
+SELECT 'foo & bar'::tsquery || 'asd & fg';
+SELECT 'foo & bar'::tsquery || !!'asd & fg'::tsquery;
+SELECT 'foo & bar'::tsquery && 'asd | fg';
-- 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: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: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' 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:C' as "false";
+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:2B 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:2B 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(' 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:2 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: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');