2 -- Sanity checks for text search catalogs
4 -- NB: we assume the oidjoins test will have caught any dangling links,
5 -- that is OID or REGPROC fields that are not zero and do not match some
6 -- row in the linked-to table. However, if we want to enforce that a link
7 -- field can't be 0, we have to check it here.
8 -- Find unexpected zero link entries
11 WHERE prsnamespace = 0 OR prsstart = 0 OR prstoken = 0 OR prsend = 0 OR
12 -- prsheadline is optional
20 WHERE dictnamespace = 0 OR dictowner = 0 OR dicttemplate = 0;
27 WHERE tmplnamespace = 0 OR tmpllexize = 0; -- tmplinit is optional
34 WHERE cfgnamespace = 0 OR cfgowner = 0 OR cfgparser = 0;
39 SELECT mapcfg, maptokentype, mapseqno
41 WHERE mapcfg = 0 OR mapdict = 0;
42 mapcfg | maptokentype | mapseqno
43 --------+--------------+----------
46 -- Look for pg_ts_config_map entries that aren't one of parser's token types
48 ( SELECT oid AS cfgid, (ts_token_type(cfgparser)).tokid AS tokid
49 FROM pg_ts_config ) AS tt
50 RIGHT JOIN pg_ts_config_map AS m
51 ON (tt.cfgid=m.mapcfg AND tt.tokid=m.maptokentype)
53 tt.cfgid IS NULL OR tt.tokid IS NULL;
54 cfgid | tokid | mapcfg | maptokentype | mapseqno | mapdict
55 -------+-------+--------+--------------+----------+---------
58 -- test basic text search behavior without indexes, then with
59 SELECT count(*) FROM test_tsvector WHERE a @@ 'wr|qh';
65 SELECT count(*) FROM test_tsvector WHERE a @@ 'wr&qh';
71 SELECT count(*) FROM test_tsvector WHERE a @@ 'eq&yt';
77 SELECT count(*) FROM test_tsvector WHERE a @@ 'eq|yt';
83 SELECT count(*) FROM test_tsvector WHERE a @@ '(eq&yt)|(wr&qh)';
89 SELECT count(*) FROM test_tsvector WHERE a @@ '(eq|yt)&(wr|qh)';
95 SELECT count(*) FROM test_tsvector WHERE a @@ 'w:*|q:*';
101 create index wowidx on test_tsvector using gist (a);
102 SET enable_seqscan=OFF;
103 SELECT count(*) FROM test_tsvector WHERE a @@ 'wr|qh';
109 SELECT count(*) FROM test_tsvector WHERE a @@ 'wr&qh';
115 SELECT count(*) FROM test_tsvector WHERE a @@ 'eq&yt';
121 SELECT count(*) FROM test_tsvector WHERE a @@ 'eq|yt';
127 SELECT count(*) FROM test_tsvector WHERE a @@ '(eq&yt)|(wr&qh)';
133 SELECT count(*) FROM test_tsvector WHERE a @@ '(eq|yt)&(wr|qh)';
139 SELECT count(*) FROM test_tsvector WHERE a @@ 'w:*|q:*';
145 RESET enable_seqscan;
147 CREATE INDEX wowidx ON test_tsvector USING gin (a);
148 SET enable_seqscan=OFF;
149 SELECT count(*) FROM test_tsvector WHERE a @@ 'wr|qh';
155 SELECT count(*) FROM test_tsvector WHERE a @@ 'wr&qh';
161 SELECT count(*) FROM test_tsvector WHERE a @@ 'eq&yt';
167 SELECT count(*) FROM test_tsvector WHERE a @@ 'eq|yt';
173 SELECT count(*) FROM test_tsvector WHERE a @@ '(eq&yt)|(wr&qh)';
179 SELECT count(*) FROM test_tsvector WHERE a @@ '(eq|yt)&(wr|qh)';
185 SELECT count(*) FROM test_tsvector WHERE a @@ 'w:*|q:*';
192 RESET enable_seqscan;
193 INSERT INTO test_tsvector VALUES ('???', 'DFG:1A,2B,6C,10 FGH');
194 SELECT * FROM ts_stat('SELECT a FROM test_tsvector') ORDER BY ndoc DESC, nentry DESC, word LIMIT 10;
196 ------+------+--------
209 SELECT * FROM ts_stat('SELECT a FROM test_tsvector', 'AB') ORDER BY ndoc DESC, nentry DESC, word;
211 ------+------+--------
215 --dictionaries and to_tsvector
216 SELECT ts_lexize('english_stem', 'skies');
222 SELECT ts_lexize('english_stem', 'identity');
228 SELECT * FROM ts_token_type('default');
229 tokid | alias | description
230 -------+-----------------+------------------------------------------
231 1 | asciiword | Word, all ASCII
232 2 | word | Word, all letters
233 3 | numword | Word, letters and digits
234 4 | email | Email address
237 7 | sfloat | Scientific notation
238 8 | version | Version number
239 9 | hword_numpart | Hyphenated word part, letters and digits
240 10 | hword_part | Hyphenated word part, all letters
241 11 | hword_asciipart | Hyphenated word part, all ASCII
242 12 | blank | Space symbols
244 14 | protocol | Protocol head
245 15 | numhword | Hyphenated word, letters and digits
246 16 | asciihword | Hyphenated word, all ASCII
247 17 | hword | Hyphenated word, all letters
248 18 | url_path | URL path
249 19 | file | File or path name
250 20 | float | Decimal notation
251 21 | int | Signed integer
252 22 | uint | Unsigned integer
253 23 | entity | XML entity
256 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>">
257 /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
258 <i <b> wow < jqw <> qwerty');
260 -------+--------------------------------------
271 5 | aew.werc.ewr/?ad=qwe&dw
275 5 | 1aew.werc.ewr/?ad=qwe&dw
282 5 | 3aew.werc.ewr/?ad=qwe&dw
290 6 | 5aew.werc.ewr:8100
298 5 | 6aew.werc.ewr:8100/?ad=qwe&dw
299 6 | 6aew.werc.ewr:8100
302 5 | 7aew.werc.ewr:8100/?ad=qwe&dw=%20%32
303 6 | 7aew.werc.ewr:8100
304 18 | /?ad=qwe&dw=%20%32
346 13 | <a href="qwe<qwe>">
396 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>">
397 /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
398 <i <b> wow < jqw <> qwerty');
400 --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
401 '+4.0e-10':26 '-4.2':58,60 '/?ad=qwe&dw':7,10,14,22 '/?ad=qwe&dw=%20%32':25 '/awdf/dwqe/4325':46 '/usr/local/fff':45 '/wqe-324/ewr':49 '1aew.werc.ewr':9 '1aew.werc.ewr/?ad=qwe&dw':8 '234':61 '234.435':30 '2aew.werc.ewr':11 '345':1 '3aew.werc.ewr':13 '3aew.werc.ewr/?ad=qwe&dw':12 '4.2':54,55,56 '455':31 '4aew.werc.ewr':15 '5.005':32 '5aew.werc.ewr:8100':16 '6aew.werc.ewr:8100':21 '6aew.werc.ewr:8100/?ad=qwe&dw':20 '7aew.werc.ewr:8100':24 '7aew.werc.ewr:8100/?ad=qwe&dw=%20%32':23 'ad':17 'aew.werc.ewr':6 'aew.werc.ewr/?ad=qwe&dw':5 'asdf':37 'dw':19 'efd.r':3 'ewr1':43 'ewri2':44 'gist.c':52 'gist.h':50 'gist.h.c':51 'hjwer':42 'jf':39 'jqw':64 'qwe':2,18,27,28,35 'qwe-wer':34 'qwer':38 'qwerti':65 'qwqwe':29 'readlin':53,57,59 'rewt/ewr':47 'sdjk':40 'teodor@stack.net':33 'wefjn':48 'wer':36 'wow':63 'www.com':4
404 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>">
405 /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
406 <i <b> wow < jqw <> qwerty'));
413 SELECT * from ts_debug('english', '<myns:foo-bar_baz.blurfl>abc&nm1;def©ghiõjkl</myns:foo-bar_baz.blurfl>');
414 alias | description | token | dictionaries | dictionary | lexemes
415 -----------+-----------------+----------------------------+----------------+--------------+---------
416 tag | XML tag | <myns:foo-bar_baz.blurfl> | {} | |
417 asciiword | Word, all ASCII | abc | {english_stem} | english_stem | {abc}
418 entity | XML entity | &nm1; | {} | |
419 asciiword | Word, all ASCII | def | {english_stem} | english_stem | {def}
420 entity | XML entity | © | {} | |
421 asciiword | Word, all ASCII | ghi | {english_stem} | english_stem | {ghi}
422 entity | XML entity | õ | {} | |
423 asciiword | Word, all ASCII | jkl | {english_stem} | english_stem | {jkl}
424 tag | XML tag | </myns:foo-bar_baz.blurfl> | {} | |
428 SELECT to_tsquery('english', 'qwe & sKies ');
434 SELECT to_tsquery('simple', 'qwe & sKies ');
440 SELECT to_tsquery('english', '''the wether'':dc & '' sKies '':BC ');
442 ------------------------
443 'wether':CD & 'sky':BC
446 SELECT to_tsquery('english', 'asd&(and|fghj)');
452 SELECT to_tsquery('english', '(asd&and)|fghj');
458 SELECT to_tsquery('english', '(asd&!and)|fghj');
464 SELECT to_tsquery('english', '(the|and&(i&1))&fghj');
470 SELECT plainto_tsquery('english', 'the and z 1))& fghj');
476 SELECT plainto_tsquery('english', 'foo bar') && plainto_tsquery('english', 'asd');
478 -----------------------
479 'foo' & 'bar' & 'asd'
482 SELECT plainto_tsquery('english', 'foo bar') || plainto_tsquery('english', 'asd fg');
484 ------------------------------
485 'foo' & 'bar' | 'asd' & 'fg'
488 SELECT plainto_tsquery('english', 'foo bar') || !!plainto_tsquery('english', 'asd fg');
490 -----------------------------------
491 'foo' & 'bar' | !( 'asd' & 'fg' )
494 SELECT plainto_tsquery('english', 'foo bar') && 'asd | fg';
496 ----------------------------------
497 'foo' & 'bar' & ( 'asd' | 'fg' )
500 SELECT ts_rank_cd(to_tsvector('english', '
501 Day after day, day after day,
502 We stuck, nor breath nor motion,
503 As idle as a painted Ship
504 Upon a painted Ocean.
505 Water, water, every where
506 And all the boards did shrink;
507 Water, water, every where,
508 Nor any drop to drink.
509 S. T. Coleridge (1772-1834)
510 '), to_tsquery('english', 'paint&water'));
516 SELECT ts_rank_cd(to_tsvector('english', '
517 Day after day, day after day,
518 We stuck, nor breath nor motion,
519 As idle as a painted Ship
520 Upon a painted Ocean.
521 Water, water, every where
522 And all the boards did shrink;
523 Water, water, every where,
524 Nor any drop to drink.
525 S. T. Coleridge (1772-1834)
526 '), to_tsquery('english', 'breath&motion&water'));
532 SELECT ts_rank_cd(to_tsvector('english', '
533 Day after day, day after day,
534 We stuck, nor breath nor motion,
535 As idle as a painted Ship
536 Upon a painted Ocean.
537 Water, water, every where
538 And all the boards did shrink;
539 Water, water, every where,
540 Nor any drop to drink.
541 S. T. Coleridge (1772-1834)
542 '), to_tsquery('english', 'ocean'));
549 SELECT ts_headline('english', '
550 Day after day, day after day,
551 We stuck, nor breath nor motion,
552 As idle as a painted Ship
553 Upon a painted Ocean.
554 Water, water, every where
555 And all the boards did shrink;
556 Water, water, every where,
557 Nor any drop to drink.
558 S. T. Coleridge (1772-1834)
559 ', to_tsquery('english', 'paint&water'));
561 -----------------------------------------
562 <b>painted</b> Ocean.
563 <b>Water</b>, <b>water</b>, every where
564 And all the boards did shrink;
565 <b>Water</b>, <b>water</b>, every
568 SELECT ts_headline('english', '
569 Day after day, day after day,
570 We stuck, nor breath nor motion,
571 As idle as a painted Ship
572 Upon a painted Ocean.
573 Water, water, every where
574 And all the boards did shrink;
575 Water, water, every where,
576 Nor any drop to drink.
577 S. T. Coleridge (1772-1834)
578 ', to_tsquery('english', 'breath&motion&water'));
580 ----------------------------------
581 <b>breath</b> nor <b>motion</b>,
582 As idle as a painted Ship
583 Upon a painted Ocean.
584 <b>Water</b>, <b>water</b>
587 SELECT ts_headline('english', '
588 Day after day, day after day,
589 We stuck, nor breath nor motion,
590 As idle as a painted Ship
591 Upon a painted Ocean.
592 Water, water, every where
593 And all the boards did shrink;
594 Water, water, every where,
595 Nor any drop to drink.
596 S. T. Coleridge (1772-1834)
597 ', to_tsquery('english', 'ocean'));
599 ----------------------------------
601 Water, water, every where
602 And all the boards did shrink;
603 Water, water, every where
606 SELECT ts_headline('english', '
608 <!-- some comment -->
610 Sea view wow <u>foo bar</u> <i>qq</i>
611 <a href="http://www.google.com/foo.bar.html" target="_blank">YES </a>
618 to_tsquery('english', 'sea&foo'), 'HighlightAll=true');
620 -----------------------------------------------------------------------------
623 <!-- some comment -->
625 <b>Sea</b> view wow <u><b>foo</b> bar</u> <i>qq</i>
626 <a href="http://www.google.com/foo.bar.html" target="_blank">YES </a>
635 --Check if headline fragments work
636 SELECT ts_headline('english', '
637 Day after day, day after day,
638 We stuck, nor breath nor motion,
639 As idle as a painted Ship
640 Upon a painted Ocean.
641 Water, water, every where
642 And all the boards did shrink;
643 Water, water, every where,
644 Nor any drop to drink.
645 S. T. Coleridge (1772-1834)
646 ', to_tsquery('english', 'ocean'), 'MaxFragments=1');
648 ------------------------------------
650 We stuck, nor breath nor motion,
651 As idle as a painted Ship
652 Upon a painted <b>Ocean</b>.
653 Water, water, every where
654 And all the boards did shrink;
655 Water, water, every where,
659 --Check if more than one fragments are displayed
660 SELECT ts_headline('english', '
661 Day after day, day after day,
662 We stuck, nor breath nor motion,
663 As idle as a painted Ship
664 Upon a painted Ocean.
665 Water, water, every where
666 And all the boards did shrink;
667 Water, water, every where,
668 Nor any drop to drink.
669 S. T. Coleridge (1772-1834)
670 ', to_tsquery('english', 'Coleridge & stuck'), 'MaxFragments=2');
672 ----------------------------------------------
673 after day, day after day,
674 We <b>stuck</b>, nor breath nor motion,
675 As idle as a painted Ship
676 Upon a painted Ocean.
677 Water, water, every where
678 And all the boards did shrink;
679 Water, water, every where ... drop to drink.
680 S. T. <b>Coleridge</b>
683 --Fragments when there all query words are not in the document
684 SELECT ts_headline('english', '
685 Day after day, day after day,
686 We stuck, nor breath nor motion,
687 As idle as a painted Ship
688 Upon a painted Ocean.
689 Water, water, every where
690 And all the boards did shrink;
691 Water, water, every where,
692 Nor any drop to drink.
693 S. T. Coleridge (1772-1834)
694 ', to_tsquery('english', 'ocean & seahorse'), 'MaxFragments=1');
696 ------------------------------------
698 Day after day, day after day,
699 We stuck, nor breath nor motion,
703 --FragmentDelimiter option
704 SELECT ts_headline('english', '
705 Day after day, day after day,
706 We stuck, nor breath nor motion,
707 As idle as a painted Ship
708 Upon a painted Ocean.
709 Water, water, every where
710 And all the boards did shrink;
711 Water, water, every where,
712 Nor any drop to drink.
713 S. T. Coleridge (1772-1834)
714 ', to_tsquery('english', 'Coleridge & stuck'), 'MaxFragments=2,FragmentDelimiter=***');
716 --------------------------------------------
717 after day, day after day,
718 We <b>stuck</b>, nor breath nor motion,
719 As idle as a painted Ship
720 Upon a painted Ocean.
721 Water, water, every where
722 And all the boards did shrink;
723 Water, water, every where***drop to drink.
724 S. T. <b>Coleridge</b>
728 CREATE TABLE test_tsquery (txtkeyword TEXT, txtsample TEXT);
730 ALTER TABLE test_tsquery ADD COLUMN keyword tsquery;
731 UPDATE test_tsquery SET keyword = to_tsquery('english', txtkeyword);
732 ALTER TABLE test_tsquery ADD COLUMN sample tsquery;
733 UPDATE test_tsquery SET sample = to_tsquery('english', txtsample::text);
734 SELECT COUNT(*) FROM test_tsquery WHERE keyword < 'new & york';
740 SELECT COUNT(*) FROM test_tsquery WHERE keyword <= 'new & york';
746 SELECT COUNT(*) FROM test_tsquery WHERE keyword = 'new & york';
752 SELECT COUNT(*) FROM test_tsquery WHERE keyword >= 'new & york';
758 SELECT COUNT(*) FROM test_tsquery WHERE keyword > 'new & york';
764 CREATE UNIQUE INDEX bt_tsq ON test_tsquery (keyword);
765 SET enable_seqscan=OFF;
766 SELECT COUNT(*) FROM test_tsquery WHERE keyword < 'new & york';
772 SELECT COUNT(*) FROM test_tsquery WHERE keyword <= 'new & york';
778 SELECT COUNT(*) FROM test_tsquery WHERE keyword = 'new & york';
784 SELECT COUNT(*) FROM test_tsquery WHERE keyword >= 'new & york';
790 SELECT COUNT(*) FROM test_tsquery WHERE keyword > 'new & york';
796 RESET enable_seqscan;
797 SELECT ts_rewrite('foo & bar & qq & new & york', 'new & york'::tsquery, 'big & apple | nyc | new & york & city');
799 ----------------------------------------------------------------------------------
800 'foo' & 'bar' & 'qq' & ( 'city' & 'new' & 'york' | ( 'nyc' | 'big' & 'apple' ) )
803 SELECT ts_rewrite('moscow', 'SELECT keyword, sample FROM test_tsquery'::text );
805 ---------------------
809 SELECT ts_rewrite('moscow & hotel', 'SELECT keyword, sample FROM test_tsquery'::text );
811 -----------------------------------
812 'hotel' & ( 'moskva' | 'moscow' )
815 SELECT ts_rewrite('bar & new & qq & foo & york', 'SELECT keyword, sample FROM test_tsquery'::text );
817 -------------------------------------------------------------------------------------
818 'citi' & 'foo' & ( 'bar' | 'qq' ) & ( 'nyc' | ( 'big' & 'appl' | 'new' & 'york' ) )
821 SELECT ts_rewrite( 'moscow', 'SELECT keyword, sample FROM test_tsquery');
823 ---------------------
827 SELECT ts_rewrite( 'moscow & hotel', 'SELECT keyword, sample FROM test_tsquery');
829 -----------------------------------
830 'hotel' & ( 'moskva' | 'moscow' )
833 SELECT ts_rewrite( 'bar & new & qq & foo & york', 'SELECT keyword, sample FROM test_tsquery');
835 -------------------------------------------------------------------------------------
836 'citi' & 'foo' & ( 'bar' | 'qq' ) & ( 'nyc' | ( 'big' & 'appl' | 'new' & 'york' ) )
839 SELECT keyword FROM test_tsquery WHERE keyword @> 'new';
845 SELECT keyword FROM test_tsquery WHERE keyword @> 'moscow';
851 SELECT keyword FROM test_tsquery WHERE keyword <@ 'new';
856 SELECT keyword FROM test_tsquery WHERE keyword <@ 'moscow';
862 SELECT ts_rewrite( query, 'SELECT keyword, sample FROM test_tsquery' ) FROM to_tsquery('english', 'moscow') AS query;
864 ---------------------
868 SELECT ts_rewrite( query, 'SELECT keyword, sample FROM test_tsquery' ) FROM to_tsquery('english', 'moscow & hotel') AS query;
870 -----------------------------------
871 'hotel' & ( 'moskva' | 'moscow' )
874 SELECT ts_rewrite( query, 'SELECT keyword, sample FROM test_tsquery' ) FROM to_tsquery('english', 'bar & new & qq & foo & york') AS query;
876 -------------------------------------------------------------------------------------
877 'citi' & 'foo' & ( 'bar' | 'qq' ) & ( 'nyc' | ( 'big' & 'appl' | 'new' & 'york' ) )
880 SELECT ts_rewrite( query, 'SELECT keyword, sample FROM test_tsquery' ) FROM to_tsquery('english', 'moscow') AS query;
882 ---------------------
886 SELECT ts_rewrite( query, 'SELECT keyword, sample FROM test_tsquery' ) FROM to_tsquery('english', 'moscow & hotel') AS query;
888 -----------------------------------
889 'hotel' & ( 'moskva' | 'moscow' )
892 SELECT ts_rewrite( query, 'SELECT keyword, sample FROM test_tsquery' ) FROM to_tsquery('english', 'bar & new & qq & foo & york') AS query;
894 -------------------------------------------------------------------------------------
895 'citi' & 'foo' & ( 'bar' | 'qq' ) & ( 'nyc' | ( 'big' & 'appl' | 'new' & 'york' ) )
898 CREATE INDEX qq ON test_tsquery USING gist (keyword tsquery_ops);
899 SET enable_seqscan=OFF;
900 SELECT keyword FROM test_tsquery WHERE keyword @> 'new';
906 SELECT keyword FROM test_tsquery WHERE keyword @> 'moscow';
912 SELECT keyword FROM test_tsquery WHERE keyword <@ 'new';
917 SELECT keyword FROM test_tsquery WHERE keyword <@ 'moscow';
923 SELECT ts_rewrite( query, 'SELECT keyword, sample FROM test_tsquery' ) FROM to_tsquery('english', 'moscow') AS query;
925 ---------------------
929 SELECT ts_rewrite( query, 'SELECT keyword, sample FROM test_tsquery' ) FROM to_tsquery('english', 'moscow & hotel') AS query;
931 -----------------------------------
932 'hotel' & ( 'moskva' | 'moscow' )
935 SELECT ts_rewrite( query, 'SELECT keyword, sample FROM test_tsquery' ) FROM to_tsquery('english', 'bar & new & qq & foo & york') AS query;
937 -------------------------------------------------------------------------------------
938 'citi' & 'foo' & ( 'bar' | 'qq' ) & ( 'nyc' | ( 'big' & 'appl' | 'new' & 'york' ) )
941 SELECT ts_rewrite( query, 'SELECT keyword, sample FROM test_tsquery' ) FROM to_tsquery('english', 'moscow') AS query;
943 ---------------------
947 SELECT ts_rewrite( query, 'SELECT keyword, sample FROM test_tsquery' ) FROM to_tsquery('english', 'moscow & hotel') AS query;
949 -----------------------------------
950 'hotel' & ( 'moskva' | 'moscow' )
953 SELECT ts_rewrite( query, 'SELECT keyword, sample FROM test_tsquery' ) FROM to_tsquery('english', 'bar & new & qq & foo & york') AS query;
955 -------------------------------------------------------------------------------------
956 'citi' & 'foo' & ( 'bar' | 'qq' ) & ( 'nyc' | ( 'big' & 'appl' | 'new' & 'york' ) )
959 RESET enable_seqscan;
961 SET default_text_search_config=simple;
962 SELECT to_tsvector('SKIES My booKs');
964 ----------------------------
965 'books':3 'my':2 'skies':1
968 SELECT plainto_tsquery('SKIES My booKs');
970 --------------------------
971 'skies' & 'my' & 'books'
974 SELECT to_tsquery('SKIES & My | booKs');
976 --------------------------
977 'skies' & 'my' | 'books'
980 SET default_text_search_config=english;
981 SELECT to_tsvector('SKIES My booKs');
987 SELECT plainto_tsquery('SKIES My booKs');
993 SELECT to_tsquery('SKIES & My | booKs');
1000 CREATE TRIGGER tsvectorupdate
1001 BEFORE UPDATE OR INSERT ON test_tsvector
1002 FOR EACH ROW EXECUTE PROCEDURE tsvector_update_trigger(a, 'pg_catalog.english', t);
1003 SELECT count(*) FROM test_tsvector WHERE a @@ to_tsquery('345&qwerty');
1009 INSERT INTO test_tsvector (t) VALUES ('345 qwerty');
1010 SELECT count(*) FROM test_tsvector WHERE a @@ to_tsquery('345&qwerty');
1016 UPDATE test_tsvector SET t = null WHERE t = '345 qwerty';
1017 SELECT count(*) FROM test_tsvector WHERE a @@ to_tsquery('345&qwerty');
1023 INSERT INTO test_tsvector (t) VALUES ('345 qwerty');
1024 SELECT count(*) FROM test_tsvector WHERE a @@ to_tsquery('345&qwerty');