{"Entry":{"collection":"type","key":"tsquery","name":"tsquery","aliases":[],"metadata":{"aliases":[],"category":"Text search","content_hash":"f5acd0879eae3680ad0a7d8785b18db25ea951c21bf78ff14a20f89bb01bafd5","imported_at":"2026-09-30T00:40:36.896869+08:00","name":"tsquery","name_zh":"","slug":"tsquery","summary":"text search query"}},"Definition":{"Collection":"type","Key":"tsquery","SourceDatabase":"center","Version":"18","SourceTable":"data_type","SourceKey":"tsquery","SourceRevision":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f","Facts":{"aliases":[],"casts":[],"catalog":{"array_type_name":"_tsquery","array_type_oid":"3645","descr":"query representation for text search","oid":"3615","typacl":"_null_","typalign":"i","typanalyze":"-","typarray":"0","typbasetype":"0","typbyval":"f","typcategory":"U","typcollation":"0","typdefault":"_null_","typdefaultbin":"_null_","typdelim":"','","typelem":"0","typinput":"tsqueryin","typisdefined":"t","typispreferred":"f","typlen":"-1","typmodin":"-","typmodout":"-","typname":"tsquery","typnamespace":"pg_catalog","typndims":"0","typnotnull":"f","typoutput":"tsqueryout","typowner":"POSTGRES","typreceive":"tsqueryrecv","typrelid":"0","typsend":"tsquerysend","typstorage":"p","typsubscript":"-","typtype":"b","typtypmod":"-1"},"comparison_data":{"aliases":[],"casts":[],"catalog":{"array_type_name":"_tsquery","typacl":"_null_","typalign":"i","typanalyze":"-","typarray":"_tsquery","typbasetype":"0","typbyval":"f","typcategory":"U","typcollation":"0","typdefault":"_null_","typdefaultbin":"_null_","typdelim":",","typelem":"0","typinput":"tsqueryin","typisdefined":"t","typispreferred":"f","typlen":"-1","typmodin":"-","typmodout":"-","typname":"tsquery","typndims":"0","typnotnull":"f","typoutput":"tsqueryout","typreceive":"tsqueryrecv","typrelid":"0","typsend":"tsquerysend","typstorage":"p","typsubscript":"-","typtype":"b","typtypmod":"-1"},"facts":[{"label":"Catalog name","value":"pg_catalog.tsquery"},{"label":"Declared length","value":"Variable length (varlena)"},{"label":"Input function","value":"tsqueryin"},{"label":"Output function","value":"tsqueryout"},{"label":"Storage strategy","value":"plain"},{"label":"Type OID","value":"3615"},{"label":"Type kind","value":"Base type"}],"operator_classes":[{"opcdefault":"t","opcfamily":"btree/tsquery_ops","opcintype":"tsquery","opckeytype":"0","opcmethod":"btree","opcname":"tsquery_ops"},{"opcdefault":"t","opcfamily":"gist/tsquery_ops","opcintype":"tsquery","opckeytype":"int8","opcmethod":"gist","opcname":"tsquery_ops"}],"operators":[{"oprcanhash":"f","oprcanmerge":"f","oprcode":"ts_match_qv","oprcom":"@@(tsvector,tsquery)","oprjoin":"tsmatchjoinsel","oprkind":"b","oprleft":"tsquery","oprname":"@@","oprnegate":"0","oprrest":"tsmatchsel","oprresult":"bool","oprright":"tsvector"},{"oprcanhash":"f","oprcanmerge":"f","oprcode":"ts_match_qv","oprcom":"@@@(tsvector,tsquery)","oprjoin":"tsmatchjoinsel","oprkind":"b","oprleft":"tsquery","oprname":"@@@","oprnegate":"0","oprrest":"tsmatchsel","oprresult":"bool","oprright":"tsvector"},{"oprcanhash":"f","oprcanmerge":"f","oprcode":"ts_match_tq","oprcom":"0","oprjoin":"matchingjoinsel","oprkind":"b","oprleft":"text","oprname":"@@","oprnegate":"0","oprrest":"matchingsel","oprresult":"bool","oprright":"tsquery"},{"oprcanhash":"f","oprcanmerge":"f","oprcode":"ts_match_vq","oprcom":"@@(tsquery,tsvector)","oprjoin":"tsmatchjoinsel","oprkind":"b","oprleft":"tsvector","oprname":"@@","oprnegate":"0","oprrest":"tsmatchsel","oprresult":"bool","oprright":"tsquery"},{"oprcanhash":"f","oprcanmerge":"f","oprcode":"ts_match_vq","oprcom":"@@@(tsquery,tsvector)","oprjoin":"tsmatchjoinsel","oprkind":"b","oprleft":"tsvector","oprname":"@@@","oprnegate":"0","oprrest":"tsmatchsel","oprresult":"bool","oprright":"tsquery"},{"oprcanhash":"f","oprcanmerge":"f","oprcode":"tsq_mcontained","oprcom":"@\u003e(tsquery,tsquery)","oprjoin":"matchingjoinsel","oprkind":"b","oprleft":"tsquery","oprname":"\u003c@","oprnegate":"0","oprrest":"matchingsel","oprresult":"bool","oprright":"tsquery"},{"oprcanhash":"f","oprcanmerge":"f","oprcode":"tsq_mcontains","oprcom":"\u003c@(tsquery,tsquery)","oprjoin":"matchingjoinsel","oprkind":"b","oprleft":"tsquery","oprname":"@\u003e","oprnegate":"0","oprrest":"matchingsel","oprresult":"bool","oprright":"tsquery"},{"oprcanhash":"f","oprcanmerge":"f","oprcode":"tsquery_and","oprcom":"0","oprjoin":"-","oprkind":"b","oprleft":"tsquery","oprname":"\u0026\u0026","oprnegate":"0","oprrest":"-","oprresult":"tsquery","oprright":"tsquery"},{"oprcanhash":"f","oprcanmerge":"f","oprcode":"tsquery_ge","oprcom":"\u003c=(tsquery,tsquery)","oprjoin":"scalargejoinsel","oprkind":"b","oprleft":"tsquery","oprname":"\u003e=","oprnegate":"\u003c(tsquery,tsquery)","oprrest":"scalargesel","oprresult":"bool","oprright":"tsquery"},{"oprcanhash":"f","oprcanmerge":"f","oprcode":"tsquery_gt","oprcom":"\u003c(tsquery,tsquery)","oprjoin":"scalargtjoinsel","oprkind":"b","oprleft":"tsquery","oprname":"\u003e","oprnegate":"\u003c=(tsquery,tsquery)","oprrest":"scalargtsel","oprresult":"bool","oprright":"tsquery"},{"oprcanhash":"f","oprcanmerge":"f","oprcode":"tsquery_le","oprcom":"\u003e=(tsquery,tsquery)","oprjoin":"scalarlejoinsel","oprkind":"b","oprleft":"tsquery","oprname":"\u003c=","oprnegate":"\u003e(tsquery,tsquery)","oprrest":"scalarlesel","oprresult":"bool","oprright":"tsquery"},{"oprcanhash":"f","oprcanmerge":"f","oprcode":"tsquery_lt","oprcom":"\u003e(tsquery,tsquery)","oprjoin":"scalarltjoinsel","oprkind":"b","oprleft":"tsquery","oprname":"\u003c","oprnegate":"\u003e=(tsquery,tsquery)","oprrest":"scalarltsel","oprresult":"bool","oprright":"tsquery"},{"oprcanhash":"f","oprcanmerge":"f","oprcode":"tsquery_ne","oprcom":"\u003c\u003e(tsquery,tsquery)","oprjoin":"neqjoinsel","oprkind":"b","oprleft":"tsquery","oprname":"\u003c\u003e","oprnegate":"=(tsquery,tsquery)","oprrest":"neqsel","oprresult":"bool","oprright":"tsquery"},{"oprcanhash":"f","oprcanmerge":"f","oprcode":"tsquery_not","oprcom":"0","oprjoin":"-","oprkind":"l","oprleft":"0","oprname":"!!","oprnegate":"0","oprrest":"-","oprresult":"tsquery","oprright":"tsquery"},{"oprcanhash":"f","oprcanmerge":"f","oprcode":"tsquery_or","oprcom":"0","oprjoin":"-","oprkind":"b","oprleft":"tsquery","oprname":"||","oprnegate":"0","oprrest":"-","oprresult":"tsquery","oprright":"tsquery"},{"oprcanhash":"f","oprcanmerge":"f","oprcode":"tsquery_phrase","oprcom":"0","oprjoin":"-","oprkind":"b","oprleft":"tsquery","oprname":"\u003c-\u003e","oprnegate":"0","oprrest":"-","oprresult":"tsquery","oprright":"tsquery"},{"oprcanhash":"f","oprcanmerge":"t","oprcode":"tsquery_eq","oprcom":"=(tsquery,tsquery)","oprjoin":"eqjoinsel","oprkind":"b","oprleft":"tsquery","oprname":"=","oprnegate":"\u003c\u003e(tsquery,tsquery)","oprrest":"eqsel","oprresult":"bool","oprright":"tsquery"}],"ranges":[]},"comparison_hash":"3aedfeb78548fb08b9eacdd463272380487f323ce2735f529196d75a402ebcec","coverage":"source inventory; exact declared input types for operator classes","description":["text search query"],"facts":[{"label":"Catalog name","value":"pg_catalog.tsquery"},{"label":"Type OID","value":"3615"},{"label":"Type kind","value":"Base type"},{"label":"Declared length","value":"Variable length (varlena)"},{"label":"Storage strategy","value":"plain"},{"label":"Input function","value":"tsqueryin"},{"label":"Output function","value":"tsqueryout"}],"manual_documentation":"dedicated family chapter","manual_html":"\u003cdiv class=\"sect1\" id=\"DATATYPE-TEXTSEARCH\"\u003e\n\u003cdiv class=\"titlepage\"\u003e\n\u003cdiv\u003e\n\u003cdiv\u003e\n\u003ch2 class=\"title\"\u003e8.11. Text Search Types \u003c/h2\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\n\u003cp\u003e\u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e provides two data types that are designed to support full text search, which is the activity of searching through a collection of natural-language \u003cem class=\"firstterm\"\u003edocuments\u003c/em\u003e to locate those that best match a \u003cem class=\"firstterm\"\u003equery\u003c/em\u003e. The \u003ccode class=\"type\"\u003etsvector\u003c/code\u003e type represents a document in a form optimized for text search; the \u003ccode class=\"type\"\u003etsquery\u003c/code\u003e type similarly represents a text query. \u003ca class=\"xref\" href=\"/docs/18/textsearch.html\" title=\"Chapter 12. Full Text Search\"\u003eChapter 12\u003c/a\u003e provides a detailed explanation of this facility, and \u003ca class=\"xref\" href=\"/docs/18/functions-textsearch.html\" title=\"9.13. Text Search Functions and Operators\"\u003eSection 9.13\u003c/a\u003e summarizes the related functions and operators.\u003c/p\u003e\n\u003cdiv class=\"sect2\" id=\"DATATYPE-TSVECTOR\"\u003e\n\u003cdiv class=\"titlepage\"\u003e\n\u003cdiv\u003e\n\u003cdiv\u003e\n\u003ch3 class=\"title\"\u003e8.11.1. \u003ccode class=\"type\"\u003etsvector\u003c/code\u003e \u003c/h3\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cp\u003eA \u003ccode class=\"type\"\u003etsvector\u003c/code\u003e value is a sorted list of distinct \u003cem class=\"firstterm\"\u003elexemes\u003c/em\u003e, which are words that have been \u003cem class=\"firstterm\"\u003enormalized\u003c/em\u003e to merge different variants of the same word (see \u003ca class=\"xref\" href=\"/docs/18/textsearch.html\" title=\"Chapter 12. Full Text Search\"\u003eChapter 12\u003c/a\u003e for details). Sorting and duplicate-elimination are done automatically during input, as shown in this example:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003eSELECT 'a fat cat sat on a mat and ate a fat rat'::tsvector;\n                      tsvector\n----------------------------------------------------\n 'a' 'and' 'ate' 'cat' 'fat' 'mat' 'on' 'rat' 'sat'\n\u003c/pre\u003e\n\u003cp\u003eTo represent lexemes containing whitespace or punctuation, surround them with quotes:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003eSELECT $$the lexeme '    ' contains spaces$$::tsvector;\n                 tsvector\n-------------------------------------------\n '    ' 'contains' 'lexeme' 'spaces' 'the'\n\u003c/pre\u003e\n\u003cp\u003e(We use dollar-quoted string literals in this example and the next one to avoid the confusion of having to double quote marks within the literals.) Embedded quotes and backslashes must be doubled:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003eSELECT $$the lexeme 'Joe''s' contains a quote$$::tsvector;\n                    tsvector\n------------------------------------------------\n 'Joe''s' 'a' 'contains' 'lexeme' 'quote' 'the'\n\u003c/pre\u003e\n\u003cp\u003eOptionally, integer \u003cem class=\"firstterm\"\u003epositions\u003c/em\u003e can be attached to lexemes:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003eSELECT 'a:1 fat:2 cat:3 sat:4 on:5 a:6 mat:7 and:8 ate:9 a:10 fat:11 rat:12'::tsvector;\n                                  tsvector\n-------------------------------------------------------------------​------------\n 'a':1,6,10 'and':8 'ate':9 'cat':3 'fat':2,11 'mat':7 'on':5 'rat':12 'sat':4\n\u003c/pre\u003e\n\u003cp\u003eA position normally indicates the source word's location in the document. Positional information can be used for \u003cem class=\"firstterm\"\u003eproximity ranking\u003c/em\u003e. Position values can range from 1 to 16383; larger numbers are silently set to 16383. Duplicate positions for the same lexeme are discarded.\u003c/p\u003e\n\u003cp\u003eLexemes that have positions can further be labeled with a \u003cem class=\"firstterm\"\u003eweight\u003c/em\u003e, which can be \u003ccode class=\"literal\"\u003eA\u003c/code\u003e, \u003ccode class=\"literal\"\u003eB\u003c/code\u003e, \u003ccode class=\"literal\"\u003eC\u003c/code\u003e, or \u003ccode class=\"literal\"\u003eD\u003c/code\u003e. \u003ccode class=\"literal\"\u003eD\u003c/code\u003e is the default and hence is not shown on output:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003eSELECT 'a:1A fat:2B,4C cat:5D'::tsvector;\n          tsvector\n----------------------------\n 'a':1A 'cat':5 'fat':2B,4C\n\u003c/pre\u003e\n\u003cp\u003eWeights are typically used to reflect document structure, for example by marking title words differently from body words. Text search ranking functions can assign different priorities to the different weight markers.\u003c/p\u003e\n\u003cp\u003eIt is important to understand that the \u003ccode class=\"type\"\u003etsvector\u003c/code\u003e type itself does not perform any word normalization; it assumes the words it is given are normalized appropriately for the application. For example,\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003eSELECT 'The Fat Rats'::tsvector;\n      tsvector\n--------------------\n 'Fat' 'Rats' 'The'\n\u003c/pre\u003e\n\u003cp\u003eFor most English-text-searching applications the above words would be considered non-normalized, but \u003ccode class=\"type\"\u003etsvector\u003c/code\u003e doesn't care. Raw document text should usually be passed through \u003ccode class=\"function\"\u003eto_tsvector\u003c/code\u003e to normalize the words appropriately for searching:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003eSELECT to_tsvector('english', 'The Fat Rats');\n   to_tsvector\n-----------------\n 'fat':2 'rat':3\n\u003c/pre\u003e\n\u003cp\u003eAgain, see \u003ca class=\"xref\" href=\"/docs/18/textsearch.html\" title=\"Chapter 12. Full Text Search\"\u003eChapter 12\u003c/a\u003e for more detail.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"sect2\" id=\"DATATYPE-TSQUERY\"\u003e\n\u003cdiv class=\"titlepage\"\u003e\n\u003cdiv\u003e\n\u003cdiv\u003e\n\u003ch3 class=\"title\"\u003e8.11.2. \u003ccode class=\"type\"\u003etsquery\u003c/code\u003e \u003c/h3\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cp\u003eA \u003ccode class=\"type\"\u003etsquery\u003c/code\u003e value stores lexemes that are to be searched for, and can combine them using the Boolean operators \u003ccode class=\"literal\"\u003e\u0026amp;\u003c/code\u003e (AND), \u003ccode class=\"literal\"\u003e|\u003c/code\u003e (OR), and \u003ccode class=\"literal\"\u003e!\u003c/code\u003e (NOT), as well as the phrase search operator \u003ccode class=\"literal\"\u003e\u0026lt;-\u0026gt;\u003c/code\u003e (FOLLOWED BY). There is also a variant \u003ccode class=\"literal\"\u003e\u0026lt;\u003cem class=\"replaceable\"\u003e\u003ccode\u003eN\u003c/code\u003e\u003c/em\u003e\u0026gt;\u003c/code\u003e of the FOLLOWED BY operator, where \u003cem class=\"replaceable\"\u003e\u003ccode\u003eN\u003c/code\u003e\u003c/em\u003e is an integer constant that specifies the distance between the two lexemes being searched for. \u003ccode class=\"literal\"\u003e\u0026lt;-\u0026gt;\u003c/code\u003e is equivalent to \u003ccode class=\"literal\"\u003e\u0026lt;1\u0026gt;\u003c/code\u003e.\u003c/p\u003e\n\u003cp\u003eParentheses can be used to enforce grouping of these operators. In the absence of parentheses, \u003ccode class=\"literal\"\u003e!\u003c/code\u003e (NOT) binds most tightly, \u003ccode class=\"literal\"\u003e\u0026lt;-\u0026gt;\u003c/code\u003e (FOLLOWED BY) next most tightly, then \u003ccode class=\"literal\"\u003e\u0026amp;\u003c/code\u003e (AND), with \u003ccode class=\"literal\"\u003e|\u003c/code\u003e (OR) binding the least tightly.\u003c/p\u003e\n\u003cp\u003eHere are some examples:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003eSELECT 'fat \u0026amp; rat'::tsquery;\n    tsquery\n---------------\n 'fat' \u0026amp; 'rat'\n\nSELECT 'fat \u0026amp; (rat | cat)'::tsquery;\n          tsquery\n---------------------------\n 'fat' \u0026amp; ( 'rat' | 'cat' )\n\nSELECT 'fat \u0026amp; rat \u0026amp; ! cat'::tsquery;\n        tsquery\n------------------------\n 'fat' \u0026amp; 'rat' \u0026amp; !'cat'\n\u003c/pre\u003e\n\u003cp\u003eOptionally, lexemes in a \u003ccode class=\"type\"\u003etsquery\u003c/code\u003e can be labeled with one or more weight letters, which restricts them to match only \u003ccode class=\"type\"\u003etsvector\u003c/code\u003e lexemes with one of those weights:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003eSELECT 'fat:ab \u0026amp; cat'::tsquery;\n    tsquery\n------------------\n 'fat':AB \u0026amp; 'cat'\n\u003c/pre\u003e\n\u003cp\u003eAlso, lexemes in a \u003ccode class=\"type\"\u003etsquery\u003c/code\u003e can be labeled with \u003ccode class=\"literal\"\u003e*\u003c/code\u003e to specify prefix matching:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003eSELECT 'super:*'::tsquery;\n  tsquery\n-----------\n 'super':*\n\u003c/pre\u003e\n\u003cp\u003eThis query will match any word in a \u003ccode class=\"type\"\u003etsvector\u003c/code\u003e that begins with \u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003esuper\u003c/span\u003e”\u003c/span\u003e.\u003c/p\u003e\n\u003cp\u003eQuoting rules for lexemes are the same as described previously for lexemes in \u003ccode class=\"type\"\u003etsvector\u003c/code\u003e; and, as with \u003ccode class=\"type\"\u003etsvector\u003c/code\u003e, any required normalization of words must be done before converting to the \u003ccode class=\"type\"\u003etsquery\u003c/code\u003e type. The \u003ccode class=\"function\"\u003eto_tsquery\u003c/code\u003e function is convenient for performing such normalization:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003eSELECT to_tsquery('Fat:ab \u0026amp; Cats');\n    to_tsquery\n------------------\n 'fat':AB \u0026amp; 'cat'\n\u003c/pre\u003e\n\u003cp\u003eNote that \u003ccode class=\"function\"\u003eto_tsquery\u003c/code\u003e will process prefixes in the same way as other words, which means this comparison returns true:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003eSELECT to_tsvector( 'postgraduate' ) @@ to_tsquery( 'postgres:*' );\n ?column?\n----------\n t\n\u003c/pre\u003e\n\u003cp\u003ebecause \u003ccode class=\"literal\"\u003epostgres\u003c/code\u003e gets stemmed to \u003ccode class=\"literal\"\u003epostgr\u003c/code\u003e:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003eSELECT to_tsvector( 'postgraduate' ), to_tsquery( 'postgres:*' );\n  to_tsvector  | to_tsquery\n---------------+------------\n 'postgradu':1 | 'postgr':*\n\u003c/pre\u003e\n\u003cp\u003ewhich will match the stemmed form of \u003ccode class=\"literal\"\u003epostgraduate\u003c/code\u003e.\u003c/p\u003e\n\u003c/div\u003e\n\u003c/div\u003e","manual_path":"datatype-textsearch.html","operator_classes":[{"opcdefault":"t","opcfamily":"btree/tsquery_ops","opcintype":"tsquery","opckeytype":"0","opcmethod":"btree","opcname":"tsquery_ops","opcnamespace":"pg_catalog","opcowner":"POSTGRES"},{"opcdefault":"t","opcfamily":"gist/tsquery_ops","opcintype":"tsquery","opckeytype":"int8","opcmethod":"gist","opcname":"tsquery_ops","opcnamespace":"pg_catalog","opcowner":"POSTGRES"}],"operators":[{"descr":"text search match","oid":"3636","oprcanhash":"f","oprcanmerge":"f","oprcode":"ts_match_vq","oprcom":"@@(tsquery,tsvector)","oprjoin":"tsmatchjoinsel","oprkind":"b","oprleft":"tsvector","oprname":"@@","oprnamespace":"pg_catalog","oprnegate":"0","oprowner":"POSTGRES","oprrest":"tsmatchsel","oprresult":"bool","oprright":"tsquery"},{"descr":"text search match","oid":"3637","oprcanhash":"f","oprcanmerge":"f","oprcode":"ts_match_qv","oprcom":"@@(tsvector,tsquery)","oprjoin":"tsmatchjoinsel","oprkind":"b","oprleft":"tsquery","oprname":"@@","oprnamespace":"pg_catalog","oprnegate":"0","oprowner":"POSTGRES","oprrest":"tsmatchsel","oprresult":"bool","oprright":"tsvector"},{"descr":"deprecated, use @@ instead","oid":"3660","oprcanhash":"f","oprcanmerge":"f","oprcode":"ts_match_vq","oprcom":"@@@(tsquery,tsvector)","oprjoin":"tsmatchjoinsel","oprkind":"b","oprleft":"tsvector","oprname":"@@@","oprnamespace":"pg_catalog","oprnegate":"0","oprowner":"POSTGRES","oprrest":"tsmatchsel","oprresult":"bool","oprright":"tsquery"},{"descr":"deprecated, use @@ instead","oid":"3661","oprcanhash":"f","oprcanmerge":"f","oprcode":"ts_match_qv","oprcom":"@@@(tsvector,tsquery)","oprjoin":"tsmatchjoinsel","oprkind":"b","oprleft":"tsquery","oprname":"@@@","oprnamespace":"pg_catalog","oprnegate":"0","oprowner":"POSTGRES","oprrest":"tsmatchsel","oprresult":"bool","oprright":"tsvector"},{"descr":"less than","oid":"3674","oprcanhash":"f","oprcanmerge":"f","oprcode":"tsquery_lt","oprcom":"\u003e(tsquery,tsquery)","oprjoin":"scalarltjoinsel","oprkind":"b","oprleft":"tsquery","oprname":"\u003c","oprnamespace":"pg_catalog","oprnegate":"\u003e=(tsquery,tsquery)","oprowner":"POSTGRES","oprrest":"scalarltsel","oprresult":"bool","oprright":"tsquery"},{"descr":"less than or equal","oid":"3675","oprcanhash":"f","oprcanmerge":"f","oprcode":"tsquery_le","oprcom":"\u003e=(tsquery,tsquery)","oprjoin":"scalarlejoinsel","oprkind":"b","oprleft":"tsquery","oprname":"\u003c=","oprnamespace":"pg_catalog","oprnegate":"\u003e(tsquery,tsquery)","oprowner":"POSTGRES","oprrest":"scalarlesel","oprresult":"bool","oprright":"tsquery"},{"descr":"equal","oid":"3676","oprcanhash":"f","oprcanmerge":"t","oprcode":"tsquery_eq","oprcom":"=(tsquery,tsquery)","oprjoin":"eqjoinsel","oprkind":"b","oprleft":"tsquery","oprname":"=","oprnamespace":"pg_catalog","oprnegate":"\u003c\u003e(tsquery,tsquery)","oprowner":"POSTGRES","oprrest":"eqsel","oprresult":"bool","oprright":"tsquery"},{"descr":"not equal","oid":"3677","oprcanhash":"f","oprcanmerge":"f","oprcode":"tsquery_ne","oprcom":"\u003c\u003e(tsquery,tsquery)","oprjoin":"neqjoinsel","oprkind":"b","oprleft":"tsquery","oprname":"\u003c\u003e","oprnamespace":"pg_catalog","oprnegate":"=(tsquery,tsquery)","oprowner":"POSTGRES","oprrest":"neqsel","oprresult":"bool","oprright":"tsquery"},{"descr":"greater than or equal","oid":"3678","oprcanhash":"f","oprcanmerge":"f","oprcode":"tsquery_ge","oprcom":"\u003c=(tsquery,tsquery)","oprjoin":"scalargejoinsel","oprkind":"b","oprleft":"tsquery","oprname":"\u003e=","oprnamespace":"pg_catalog","oprnegate":"\u003c(tsquery,tsquery)","oprowner":"POSTGRES","oprrest":"scalargesel","oprresult":"bool","oprright":"tsquery"},{"descr":"greater than","oid":"3679","oprcanhash":"f","oprcanmerge":"f","oprcode":"tsquery_gt","oprcom":"\u003c(tsquery,tsquery)","oprjoin":"scalargtjoinsel","oprkind":"b","oprleft":"tsquery","oprname":"\u003e","oprnamespace":"pg_catalog","oprnegate":"\u003c=(tsquery,tsquery)","oprowner":"POSTGRES","oprrest":"scalargtsel","oprresult":"bool","oprright":"tsquery"},{"descr":"AND-concatenate","oid":"3680","oprcanhash":"f","oprcanmerge":"f","oprcode":"tsquery_and","oprcom":"0","oprjoin":"-","oprkind":"b","oprleft":"tsquery","oprname":"\u0026\u0026","oprnamespace":"pg_catalog","oprnegate":"0","oprowner":"POSTGRES","oprrest":"-","oprresult":"tsquery","oprright":"tsquery"},{"descr":"OR-concatenate","oid":"3681","oprcanhash":"f","oprcanmerge":"f","oprcode":"tsquery_or","oprcom":"0","oprjoin":"-","oprkind":"b","oprleft":"tsquery","oprname":"||","oprnamespace":"pg_catalog","oprnegate":"0","oprowner":"POSTGRES","oprrest":"-","oprresult":"tsquery","oprright":"tsquery"},{"descr":"phrase-concatenate","oid":"5005","oprcanhash":"f","oprcanmerge":"f","oprcode":"tsquery_phrase(tsquery,tsquery)","oprcom":"0","oprjoin":"-","oprkind":"b","oprleft":"tsquery","oprname":"\u003c-\u003e","oprnamespace":"pg_catalog","oprnegate":"0","oprowner":"POSTGRES","oprrest":"-","oprresult":"tsquery","oprright":"tsquery"},{"descr":"NOT tsquery","oid":"3682","oprcanhash":"f","oprcanmerge":"f","oprcode":"tsquery_not","oprcom":"0","oprjoin":"-","oprkind":"l","oprleft":"0","oprname":"!!","oprnamespace":"pg_catalog","oprnegate":"0","oprowner":"POSTGRES","oprrest":"-","oprresult":"tsquery","oprright":"tsquery"},{"descr":"contains","oid":"3693","oprcanhash":"f","oprcanmerge":"f","oprcode":"tsq_mcontains","oprcom":"\u003c@(tsquery,tsquery)","oprjoin":"matchingjoinsel","oprkind":"b","oprleft":"tsquery","oprname":"@\u003e","oprnamespace":"pg_catalog","oprnegate":"0","oprowner":"POSTGRES","oprrest":"matchingsel","oprresult":"bool","oprright":"tsquery"},{"descr":"is contained by","oid":"3694","oprcanhash":"f","oprcanmerge":"f","oprcode":"tsq_mcontained","oprcom":"@\u003e(tsquery,tsquery)","oprjoin":"matchingjoinsel","oprkind":"b","oprleft":"tsquery","oprname":"\u003c@","oprnamespace":"pg_catalog","oprnegate":"0","oprowner":"POSTGRES","oprrest":"matchingsel","oprresult":"bool","oprright":"tsquery"},{"descr":"text search match","oid":"3763","oprcanhash":"f","oprcanmerge":"f","oprcode":"ts_match_tq","oprcom":"0","oprjoin":"matchingjoinsel","oprkind":"b","oprleft":"text","oprname":"@@","oprnamespace":"pg_catalog","oprnegate":"0","oprowner":"POSTGRES","oprrest":"matchingsel","oprresult":"bool","oprright":"tsquery"}],"ranges":[],"related":[{"label":"pg_type catalog","url":"/wiki/catalog/pg_type/?v=18"},{"label":"pg_cast catalog","url":"/wiki/catalog/pg_cast/?v=18"},{"label":"pg_operator catalog","url":"/wiki/catalog/pg_operator/?v=18"},{"label":"pg_opclass catalog","url":"/wiki/catalog/pg_opclass/?v=18"},{"label":"Arrays","url":"/wiki/type/arrays/?v=18"},{"label":"btree index access method","url":"/wiki/indexam/btree/?v=18"},{"label":"gist index access method","url":"/wiki/indexam/gist/?v=18"}],"release":{"channel":"stable","label":"18.6","major":"18","manual_sha256":{"arrays.html":"0e1d5c5a7b4a949d4439995f44f74ad4264e050d16eb9ad2a850fbaee04032df","catalog-pg-type.html":"ea9c9313bab8e92a7da18ebc50c7ff1f908dd80999a7e0ca3bbc82ba626c58d4","datatype-binary.html":"0c03ec47b76e37888a3da7f5dcfd340128a5d356642a85185cc9ebe17856a904","datatype-bit.html":"c49124aad561636c18080b9e09572fde7785a6b9eae86f5a33283f0fd6774c37","datatype-boolean.html":"b633f663e6c8276e7056287640c413aa79dbc15d5353cee0d41653d58d376956","datatype-character.html":"c73eebe413ea709a7792e4cfc3cfe9fb68cb496ebe83c3ebaa9d09f8c40d0f73","datatype-datetime.html":"e366275d8b13845bfa4ef0d68faa093e5f3ecb708a1ec870cbcbf7e425b85699","datatype-enum.html":"cab38e53222e30cc94b24de4b33634fd22d7c93f58ebcf35f646c9b8da78fae8","datatype-geometric.html":"0eb3053cfe7d6b0a4b5592c5d7af8d97cae527e87f063c5793413bcba5c14cd9","datatype-json.html":"650162a05b660146b500a205d523374d00aee117a6a6240d30262be51b6e33e5","datatype-money.html":"8b29c14b90679683ac5c472b59a0a7e2853f32cc7db43fab417b2697a6879964","datatype-net-types.html":"96846e641cc37727ddcd8b8a1aa0dbe33cd9787760a2b4efb0dcb9403d5be63f","datatype-numeric.html":"b74619f7ac2f1ca9f85c48073df78c33dd30e464e61baba6008634534edcb500","datatype-oid.html":"8b3360302225f08ae72716ce1804596de95b568e5d31f788cb4597427b28cc38","datatype-pg-lsn.html":"339172f5107cc7eb7139bec911277647219e92a532cebd0f3da0a5dacf8195af","datatype-pseudo.html":"c7cf0b8214304bd8702c95f2142671ae5f0d631f83717f9c07d9e1f2579961b4","datatype-textsearch.html":"4b15e05be8b49a71b28aea22f2c46d0dbf639a91e7b4fe129a4c737c6daad47c","datatype-uuid.html":"292b307b3223c6182bdba687e7f69e6dca9038430143ad79d56327f6ed4c3246","datatype-xml.html":"061fc2295b7b69be704f0a741b8decd10ad721059f871fb0243c669bb54d7822","datatype.html":"e581f67c74e42006289638c8659e9b338adbfd7f068bd8bf2b3be3880fcd2254","domains.html":"82d486973ccc35d14276627a67ac76b434452f23f9ed4d8aa3fbb01fdf285fc2","functions-info.html":"78ac80bf81da2e4f4a33f3b850faa86f0f58ec54a083d6c31da557907de0df87","rangetypes.html":"e4960abc7ce8e51d794f94f1e57b099d30b7f75dd7f2b23a960eef91f6291c33","rowtypes.html":"74f99e029c3a9edfd3e18810ba3c8cb66d3aada91eb67b86476560871e6617e9","sql-createdomain.html":"e94f927196de1b0ea1ce35cd4603c1f6f544439adcc0edf1c4222358e832245b"},"ref":"https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2","revision":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f","source_files":{"doc/src/sgml/datatype.sgml":"86328daa77e20d81d222376ec0306d9841a17104e436c08d138eb763aefb3700","src/include/catalog/pg_am.dat":"b3cb86b102a42fb0024cbd99779c9897afb40d12a71f5cc5a0e5aee7ff2f9969","src/include/catalog/pg_am.h":"3426799df799f32163fcc0765f43dbdb5e88e626acf31284fef9fc6014b69d8e","src/include/catalog/pg_cast.dat":"97911281ca2c81917394ccb2ec13367e37c6801fd461d5e1a3d2f28b911b46b2","src/include/catalog/pg_cast.h":"de585c7df687d698e7d1d100dce8a794ac9da52414ea48169191019178c8f053","src/include/catalog/pg_opclass.dat":"4ee7d3619a6aa106e1c0db55de903931c7d11b1c60ba053a022519c55f8ee668","src/include/catalog/pg_opclass.h":"9c218537806c8ef0398302faaca7f91315dfc1198c48706cebffb479b68defaf","src/include/catalog/pg_operator.dat":"5d35b9b2ef5f9797cc815263927ef8a12367fedace53e828b4e8b320e2a7f703","src/include/catalog/pg_operator.h":"621b18cfffe102413d79b746ce7a10f77fc60fdd097bac34c22b31070d3ee3c4","src/include/catalog/pg_opfamily.dat":"3b694879027b858f2ecf1fa1152b7e30c6e15a216ba99c2384291c30e9d52311","src/include/catalog/pg_opfamily.h":"e1f5fc8aebd3042df847455bf66bf755f768c2aa8a9b03d22f7ec8563eba59c0","src/include/catalog/pg_proc.dat":"1f934ce80d460159dda137714374a35f9896315ea2476709cbb4da13b38ef95a","src/include/catalog/pg_proc.h":"f7d59f07c5b95e2f3c7141762a0f576e8a3af7581ba54c27537f4d500472bea5","src/include/catalog/pg_range.dat":"5c2271f8e89e9378d1887204e5785060b77405b5f0ff3e6c719250c9c1dcfcc4","src/include/catalog/pg_range.h":"45546d952b5181f989bd9234721897fc2b37005c8e49ce2ddc156f26974c3ca4","src/include/catalog/pg_type.dat":"5f5887b75677cba2d4a1a0cfeb355df5ed91f85d385fac88bd8d7c605b3578f9","src/include/catalog/pg_type.h":"8fb198749fd82b6c1818a3c18455f226f66116fcfeb3d4959c65ce3fda22802e"},"source_sha256":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f"},"sections":[],"signature":"tsquery","sources":[{"label":"PostgreSQL 18 English manual","path":"datatype-textsearch.html","sha256":"4b15e05be8b49a71b28aea22f2c46d0dbf639a91e7b4fe129a4c737c6daad47c","url":"/docs/18/datatype-textsearch.html"},{"label":"Matching PostgreSQL source archive","sha256":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f","url":"https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2"}]},"ManualEvidence":{"manual_path":"datatype-textsearch.html","release":{"channel":"stable","label":"18.6","major":"18","manual_sha256":{"arrays.html":"0e1d5c5a7b4a949d4439995f44f74ad4264e050d16eb9ad2a850fbaee04032df","catalog-pg-type.html":"ea9c9313bab8e92a7da18ebc50c7ff1f908dd80999a7e0ca3bbc82ba626c58d4","datatype-binary.html":"0c03ec47b76e37888a3da7f5dcfd340128a5d356642a85185cc9ebe17856a904","datatype-bit.html":"c49124aad561636c18080b9e09572fde7785a6b9eae86f5a33283f0fd6774c37","datatype-boolean.html":"b633f663e6c8276e7056287640c413aa79dbc15d5353cee0d41653d58d376956","datatype-character.html":"c73eebe413ea709a7792e4cfc3cfe9fb68cb496ebe83c3ebaa9d09f8c40d0f73","datatype-datetime.html":"e366275d8b13845bfa4ef0d68faa093e5f3ecb708a1ec870cbcbf7e425b85699","datatype-enum.html":"cab38e53222e30cc94b24de4b33634fd22d7c93f58ebcf35f646c9b8da78fae8","datatype-geometric.html":"0eb3053cfe7d6b0a4b5592c5d7af8d97cae527e87f063c5793413bcba5c14cd9","datatype-json.html":"650162a05b660146b500a205d523374d00aee117a6a6240d30262be51b6e33e5","datatype-money.html":"8b29c14b90679683ac5c472b59a0a7e2853f32cc7db43fab417b2697a6879964","datatype-net-types.html":"96846e641cc37727ddcd8b8a1aa0dbe33cd9787760a2b4efb0dcb9403d5be63f","datatype-numeric.html":"b74619f7ac2f1ca9f85c48073df78c33dd30e464e61baba6008634534edcb500","datatype-oid.html":"8b3360302225f08ae72716ce1804596de95b568e5d31f788cb4597427b28cc38","datatype-pg-lsn.html":"339172f5107cc7eb7139bec911277647219e92a532cebd0f3da0a5dacf8195af","datatype-pseudo.html":"c7cf0b8214304bd8702c95f2142671ae5f0d631f83717f9c07d9e1f2579961b4","datatype-textsearch.html":"4b15e05be8b49a71b28aea22f2c46d0dbf639a91e7b4fe129a4c737c6daad47c","datatype-uuid.html":"292b307b3223c6182bdba687e7f69e6dca9038430143ad79d56327f6ed4c3246","datatype-xml.html":"061fc2295b7b69be704f0a741b8decd10ad721059f871fb0243c669bb54d7822","datatype.html":"e581f67c74e42006289638c8659e9b338adbfd7f068bd8bf2b3be3880fcd2254","domains.html":"82d486973ccc35d14276627a67ac76b434452f23f9ed4d8aa3fbb01fdf285fc2","functions-info.html":"78ac80bf81da2e4f4a33f3b850faa86f0f58ec54a083d6c31da557907de0df87","rangetypes.html":"e4960abc7ce8e51d794f94f1e57b099d30b7f75dd7f2b23a960eef91f6291c33","rowtypes.html":"74f99e029c3a9edfd3e18810ba3c8cb66d3aada91eb67b86476560871e6617e9","sql-createdomain.html":"e94f927196de1b0ea1ce35cd4603c1f6f544439adcc0edf1c4222358e832245b"},"ref":"https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2","revision":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f","source_files":{"doc/src/sgml/datatype.sgml":"86328daa77e20d81d222376ec0306d9841a17104e436c08d138eb763aefb3700","src/include/catalog/pg_am.dat":"b3cb86b102a42fb0024cbd99779c9897afb40d12a71f5cc5a0e5aee7ff2f9969","src/include/catalog/pg_am.h":"3426799df799f32163fcc0765f43dbdb5e88e626acf31284fef9fc6014b69d8e","src/include/catalog/pg_cast.dat":"97911281ca2c81917394ccb2ec13367e37c6801fd461d5e1a3d2f28b911b46b2","src/include/catalog/pg_cast.h":"de585c7df687d698e7d1d100dce8a794ac9da52414ea48169191019178c8f053","src/include/catalog/pg_opclass.dat":"4ee7d3619a6aa106e1c0db55de903931c7d11b1c60ba053a022519c55f8ee668","src/include/catalog/pg_opclass.h":"9c218537806c8ef0398302faaca7f91315dfc1198c48706cebffb479b68defaf","src/include/catalog/pg_operator.dat":"5d35b9b2ef5f9797cc815263927ef8a12367fedace53e828b4e8b320e2a7f703","src/include/catalog/pg_operator.h":"621b18cfffe102413d79b746ce7a10f77fc60fdd097bac34c22b31070d3ee3c4","src/include/catalog/pg_opfamily.dat":"3b694879027b858f2ecf1fa1152b7e30c6e15a216ba99c2384291c30e9d52311","src/include/catalog/pg_opfamily.h":"e1f5fc8aebd3042df847455bf66bf755f768c2aa8a9b03d22f7ec8563eba59c0","src/include/catalog/pg_proc.dat":"1f934ce80d460159dda137714374a35f9896315ea2476709cbb4da13b38ef95a","src/include/catalog/pg_proc.h":"f7d59f07c5b95e2f3c7141762a0f576e8a3af7581ba54c27537f4d500472bea5","src/include/catalog/pg_range.dat":"5c2271f8e89e9378d1887204e5785060b77405b5f0ff3e6c719250c9c1dcfcc4","src/include/catalog/pg_range.h":"45546d952b5181f989bd9234721897fc2b37005c8e49ce2ddc156f26974c3ca4","src/include/catalog/pg_type.dat":"5f5887b75677cba2d4a1a0cfeb355df5ed91f85d385fac88bd8d7c605b3578f9","src/include/catalog/pg_type.h":"8fb198749fd82b6c1818a3c18455f226f66116fcfeb3d4959c65ce3fda22802e"},"source_sha256":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f"},"sources":[{"label":"PostgreSQL 18 English manual","path":"datatype-textsearch.html","sha256":"4b15e05be8b49a71b28aea22f2c46d0dbf639a91e7b4fe129a4c737c6daad47c","url":"/docs/18/datatype-textsearch.html"},{"label":"Matching PostgreSQL source archive","sha256":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f","url":"https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2"}]},"MeasuredEvidence":{}},"Text":{"Collection":"type","Key":"tsquery","SourceDatabase":"center","Version":"18","Locale":"en","Title":"tsquery","Summary":"text search query","BodyHTML":"\u003cdiv id=\"DATATYPE-TEXTSEARCH\"\u003e\n\u003cdiv\u003e\n\u003cdiv\u003e\n\u003cdiv\u003e\n\u003ch2\u003e8.11. Text Search Types \u003c/h2\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\n\u003cp\u003e\u003cspan\u003ePostgreSQL\u003c/span\u003e provides two data types that are designed to support full text search, which is the activity of searching through a collection of natural-language \u003cem\u003edocuments\u003c/em\u003e to locate those that best match a \u003cem\u003equery\u003c/em\u003e. The \u003ccode\u003etsvector\u003c/code\u003e type represents a document in a form optimized for text search; the \u003ccode\u003etsquery\u003c/code\u003e type similarly represents a text query. \u003ca href=\"/docs/18/textsearch.html\" rel=\"nofollow\"\u003eChapter 12\u003c/a\u003e provides a detailed explanation of this facility, and \u003ca href=\"/docs/18/functions-textsearch.html\" rel=\"nofollow\"\u003eSection 9.13\u003c/a\u003e summarizes the related functions and operators.\u003c/p\u003e\n\u003cdiv id=\"DATATYPE-TSVECTOR\"\u003e\n\u003cdiv\u003e\n\u003cdiv\u003e\n\u003cdiv\u003e\n\u003ch3\u003e8.11.1. \u003ccode\u003etsvector\u003c/code\u003e \u003c/h3\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cp\u003eA \u003ccode\u003etsvector\u003c/code\u003e value is a sorted list of distinct \u003cem\u003elexemes\u003c/em\u003e, which are words that have been \u003cem\u003enormalized\u003c/em\u003e to merge different variants of the same word (see \u003ca href=\"/docs/18/textsearch.html\" rel=\"nofollow\"\u003eChapter 12\u003c/a\u003e for details). Sorting and duplicate-elimination are done automatically during input, as shown in this example:\u003c/p\u003e\n\u003cpre\u003eSELECT \u0026#39;a fat cat sat on a mat and ate a fat rat\u0026#39;::tsvector;\n                      tsvector\n----------------------------------------------------\n \u0026#39;a\u0026#39; \u0026#39;and\u0026#39; \u0026#39;ate\u0026#39; \u0026#39;cat\u0026#39; \u0026#39;fat\u0026#39; \u0026#39;mat\u0026#39; \u0026#39;on\u0026#39; \u0026#39;rat\u0026#39; \u0026#39;sat\u0026#39;\n\u003c/pre\u003e\n\u003cp\u003eTo represent lexemes containing whitespace or punctuation, surround them with quotes:\u003c/p\u003e\n\u003cpre\u003eSELECT $$the lexeme \u0026#39;    \u0026#39; contains spaces$$::tsvector;\n                 tsvector\n-------------------------------------------\n \u0026#39;    \u0026#39; \u0026#39;contains\u0026#39; \u0026#39;lexeme\u0026#39; \u0026#39;spaces\u0026#39; \u0026#39;the\u0026#39;\n\u003c/pre\u003e\n\u003cp\u003e(We use dollar-quoted string literals in this example and the next one to avoid the confusion of having to double quote marks within the literals.) Embedded quotes and backslashes must be doubled:\u003c/p\u003e\n\u003cpre\u003eSELECT $$the lexeme \u0026#39;Joe\u0026#39;\u0026#39;s\u0026#39; contains a quote$$::tsvector;\n                    tsvector\n------------------------------------------------\n \u0026#39;Joe\u0026#39;\u0026#39;s\u0026#39; \u0026#39;a\u0026#39; \u0026#39;contains\u0026#39; \u0026#39;lexeme\u0026#39; \u0026#39;quote\u0026#39; \u0026#39;the\u0026#39;\n\u003c/pre\u003e\n\u003cp\u003eOptionally, integer \u003cem\u003epositions\u003c/em\u003e can be attached to lexemes:\u003c/p\u003e\n\u003cpre\u003eSELECT \u0026#39;a:1 fat:2 cat:3 sat:4 on:5 a:6 mat:7 and:8 ate:9 a:10 fat:11 rat:12\u0026#39;::tsvector;\n                                  tsvector\n-------------------------------------------------------------------​------------\n \u0026#39;a\u0026#39;:1,6,10 \u0026#39;and\u0026#39;:8 \u0026#39;ate\u0026#39;:9 \u0026#39;cat\u0026#39;:3 \u0026#39;fat\u0026#39;:2,11 \u0026#39;mat\u0026#39;:7 \u0026#39;on\u0026#39;:5 \u0026#39;rat\u0026#39;:12 \u0026#39;sat\u0026#39;:4\n\u003c/pre\u003e\n\u003cp\u003eA position normally indicates the source word\u0026#39;s location in the document. Positional information can be used for \u003cem\u003eproximity ranking\u003c/em\u003e. Position values can range from 1 to 16383; larger numbers are silently set to 16383. Duplicate positions for the same lexeme are discarded.\u003c/p\u003e\n\u003cp\u003eLexemes that have positions can further be labeled with a \u003cem\u003eweight\u003c/em\u003e, which can be \u003ccode\u003eA\u003c/code\u003e, \u003ccode\u003eB\u003c/code\u003e, \u003ccode\u003eC\u003c/code\u003e, or \u003ccode\u003eD\u003c/code\u003e. \u003ccode\u003eD\u003c/code\u003e is the default and hence is not shown on output:\u003c/p\u003e\n\u003cpre\u003eSELECT \u0026#39;a:1A fat:2B,4C cat:5D\u0026#39;::tsvector;\n          tsvector\n----------------------------\n \u0026#39;a\u0026#39;:1A \u0026#39;cat\u0026#39;:5 \u0026#39;fat\u0026#39;:2B,4C\n\u003c/pre\u003e\n\u003cp\u003eWeights are typically used to reflect document structure, for example by marking title words differently from body words. Text search ranking functions can assign different priorities to the different weight markers.\u003c/p\u003e\n\u003cp\u003eIt is important to understand that the \u003ccode\u003etsvector\u003c/code\u003e type itself does not perform any word normalization; it assumes the words it is given are normalized appropriately for the application. For example,\u003c/p\u003e\n\u003cpre\u003eSELECT \u0026#39;The Fat Rats\u0026#39;::tsvector;\n      tsvector\n--------------------\n \u0026#39;Fat\u0026#39; \u0026#39;Rats\u0026#39; \u0026#39;The\u0026#39;\n\u003c/pre\u003e\n\u003cp\u003eFor most English-text-searching applications the above words would be considered non-normalized, but \u003ccode\u003etsvector\u003c/code\u003e doesn\u0026#39;t care. Raw document text should usually be passed through \u003ccode\u003eto_tsvector\u003c/code\u003e to normalize the words appropriately for searching:\u003c/p\u003e\n\u003cpre\u003eSELECT to_tsvector(\u0026#39;english\u0026#39;, \u0026#39;The Fat Rats\u0026#39;);\n   to_tsvector\n-----------------\n \u0026#39;fat\u0026#39;:2 \u0026#39;rat\u0026#39;:3\n\u003c/pre\u003e\n\u003cp\u003eAgain, see \u003ca href=\"/docs/18/textsearch.html\" rel=\"nofollow\"\u003eChapter 12\u003c/a\u003e for more detail.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv id=\"DATATYPE-TSQUERY\"\u003e\n\u003cdiv\u003e\n\u003cdiv\u003e\n\u003cdiv\u003e\n\u003ch3\u003e8.11.2. \u003ccode\u003etsquery\u003c/code\u003e \u003c/h3\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cp\u003eA \u003ccode\u003etsquery\u003c/code\u003e value stores lexemes that are to be searched for, and can combine them using the Boolean operators \u003ccode\u003e\u0026amp;\u003c/code\u003e (AND), \u003ccode\u003e|\u003c/code\u003e (OR), and \u003ccode\u003e!\u003c/code\u003e (NOT), as well as the phrase search operator \u003ccode\u003e\u0026lt;-\u0026gt;\u003c/code\u003e (FOLLOWED BY). There is also a variant \u003ccode\u003e\u0026lt;\u003cem\u003e\u003ccode\u003eN\u003c/code\u003e\u003c/em\u003e\u0026gt;\u003c/code\u003e of the FOLLOWED BY operator, where \u003cem\u003e\u003ccode\u003eN\u003c/code\u003e\u003c/em\u003e is an integer constant that specifies the distance between the two lexemes being searched for. \u003ccode\u003e\u0026lt;-\u0026gt;\u003c/code\u003e is equivalent to \u003ccode\u003e\u0026lt;1\u0026gt;\u003c/code\u003e.\u003c/p\u003e\n\u003cp\u003eParentheses can be used to enforce grouping of these operators. In the absence of parentheses, \u003ccode\u003e!\u003c/code\u003e (NOT) binds most tightly, \u003ccode\u003e\u0026lt;-\u0026gt;\u003c/code\u003e (FOLLOWED BY) next most tightly, then \u003ccode\u003e\u0026amp;\u003c/code\u003e (AND), with \u003ccode\u003e|\u003c/code\u003e (OR) binding the least tightly.\u003c/p\u003e\n\u003cp\u003eHere are some examples:\u003c/p\u003e\n\u003cpre\u003eSELECT \u0026#39;fat \u0026amp; rat\u0026#39;::tsquery;\n    tsquery\n---------------\n \u0026#39;fat\u0026#39; \u0026amp; \u0026#39;rat\u0026#39;\n\nSELECT \u0026#39;fat \u0026amp; (rat | cat)\u0026#39;::tsquery;\n          tsquery\n---------------------------\n \u0026#39;fat\u0026#39; \u0026amp; ( \u0026#39;rat\u0026#39; | \u0026#39;cat\u0026#39; )\n\nSELECT \u0026#39;fat \u0026amp; rat \u0026amp; ! cat\u0026#39;::tsquery;\n        tsquery\n------------------------\n \u0026#39;fat\u0026#39; \u0026amp; \u0026#39;rat\u0026#39; \u0026amp; !\u0026#39;cat\u0026#39;\n\u003c/pre\u003e\n\u003cp\u003eOptionally, lexemes in a \u003ccode\u003etsquery\u003c/code\u003e can be labeled with one or more weight letters, which restricts them to match only \u003ccode\u003etsvector\u003c/code\u003e lexemes with one of those weights:\u003c/p\u003e\n\u003cpre\u003eSELECT \u0026#39;fat:ab \u0026amp; cat\u0026#39;::tsquery;\n    tsquery\n------------------\n \u0026#39;fat\u0026#39;:AB \u0026amp; \u0026#39;cat\u0026#39;\n\u003c/pre\u003e\n\u003cp\u003eAlso, lexemes in a \u003ccode\u003etsquery\u003c/code\u003e can be labeled with \u003ccode\u003e*\u003c/code\u003e to specify prefix matching:\u003c/p\u003e\n\u003cpre\u003eSELECT \u0026#39;super:*\u0026#39;::tsquery;\n  tsquery\n-----------\n \u0026#39;super\u0026#39;:*\n\u003c/pre\u003e\n\u003cp\u003eThis query will match any word in a \u003ccode\u003etsvector\u003c/code\u003e that begins with \u003cspan\u003e“\u003cspan\u003esuper\u003c/span\u003e”\u003c/span\u003e.\u003c/p\u003e\n\u003cp\u003eQuoting rules for lexemes are the same as described previously for lexemes in \u003ccode\u003etsvector\u003c/code\u003e; and, as with \u003ccode\u003etsvector\u003c/code\u003e, any required normalization of words must be done before converting to the \u003ccode\u003etsquery\u003c/code\u003e type. The \u003ccode\u003eto_tsquery\u003c/code\u003e function is convenient for performing such normalization:\u003c/p\u003e\n\u003cpre\u003eSELECT to_tsquery(\u0026#39;Fat:ab \u0026amp; Cats\u0026#39;);\n    to_tsquery\n------------------\n \u0026#39;fat\u0026#39;:AB \u0026amp; \u0026#39;cat\u0026#39;\n\u003c/pre\u003e\n\u003cp\u003eNote that \u003ccode\u003eto_tsquery\u003c/code\u003e will process prefixes in the same way as other words, which means this comparison returns true:\u003c/p\u003e\n\u003cpre\u003eSELECT to_tsvector( \u0026#39;postgraduate\u0026#39; ) @@ to_tsquery( \u0026#39;postgres:*\u0026#39; );\n ?column?\n----------\n t\n\u003c/pre\u003e\n\u003cp\u003ebecause \u003ccode\u003epostgres\u003c/code\u003e gets stemmed to \u003ccode\u003epostgr\u003c/code\u003e:\u003c/p\u003e\n\u003cpre\u003eSELECT to_tsvector( \u0026#39;postgraduate\u0026#39; ), to_tsquery( \u0026#39;postgres:*\u0026#39; );\n  to_tsvector  | to_tsquery\n---------------+------------\n \u0026#39;postgradu\u0026#39;:1 | \u0026#39;postgr\u0026#39;:*\n\u003c/pre\u003e\n\u003cp\u003ewhich will match the stemmed form of \u003ccode\u003epostgraduate\u003c/code\u003e.\u003c/p\u003e\n\u003c/div\u003e\n\u003c/div\u003e","SourceRevision":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f","ContentHash":"1e978e460e054dd084ef0f4126fab99709736360114d38c7fcfe3d28c8fa5c54","Payload":{"description":["text search query"],"manual_html":"\u003cdiv class=\"sect1\" id=\"DATATYPE-TEXTSEARCH\"\u003e\n\u003cdiv class=\"titlepage\"\u003e\n\u003cdiv\u003e\n\u003cdiv\u003e\n\u003ch2 class=\"title\"\u003e8.11. Text Search Types \u003c/h2\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\n\u003cp\u003e\u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e provides two data types that are designed to support full text search, which is the activity of searching through a collection of natural-language \u003cem class=\"firstterm\"\u003edocuments\u003c/em\u003e to locate those that best match a \u003cem class=\"firstterm\"\u003equery\u003c/em\u003e. The \u003ccode class=\"type\"\u003etsvector\u003c/code\u003e type represents a document in a form optimized for text search; the \u003ccode class=\"type\"\u003etsquery\u003c/code\u003e type similarly represents a text query. \u003ca class=\"xref\" href=\"/docs/18/textsearch.html\" title=\"Chapter 12. Full Text Search\"\u003eChapter 12\u003c/a\u003e provides a detailed explanation of this facility, and \u003ca class=\"xref\" href=\"/docs/18/functions-textsearch.html\" title=\"9.13. Text Search Functions and Operators\"\u003eSection 9.13\u003c/a\u003e summarizes the related functions and operators.\u003c/p\u003e\n\u003cdiv class=\"sect2\" id=\"DATATYPE-TSVECTOR\"\u003e\n\u003cdiv class=\"titlepage\"\u003e\n\u003cdiv\u003e\n\u003cdiv\u003e\n\u003ch3 class=\"title\"\u003e8.11.1. \u003ccode class=\"type\"\u003etsvector\u003c/code\u003e \u003c/h3\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cp\u003eA \u003ccode class=\"type\"\u003etsvector\u003c/code\u003e value is a sorted list of distinct \u003cem class=\"firstterm\"\u003elexemes\u003c/em\u003e, which are words that have been \u003cem class=\"firstterm\"\u003enormalized\u003c/em\u003e to merge different variants of the same word (see \u003ca class=\"xref\" href=\"/docs/18/textsearch.html\" title=\"Chapter 12. Full Text Search\"\u003eChapter 12\u003c/a\u003e for details). Sorting and duplicate-elimination are done automatically during input, as shown in this example:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003eSELECT 'a fat cat sat on a mat and ate a fat rat'::tsvector;\n                      tsvector\n----------------------------------------------------\n 'a' 'and' 'ate' 'cat' 'fat' 'mat' 'on' 'rat' 'sat'\n\u003c/pre\u003e\n\u003cp\u003eTo represent lexemes containing whitespace or punctuation, surround them with quotes:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003eSELECT $$the lexeme '    ' contains spaces$$::tsvector;\n                 tsvector\n-------------------------------------------\n '    ' 'contains' 'lexeme' 'spaces' 'the'\n\u003c/pre\u003e\n\u003cp\u003e(We use dollar-quoted string literals in this example and the next one to avoid the confusion of having to double quote marks within the literals.) Embedded quotes and backslashes must be doubled:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003eSELECT $$the lexeme 'Joe''s' contains a quote$$::tsvector;\n                    tsvector\n------------------------------------------------\n 'Joe''s' 'a' 'contains' 'lexeme' 'quote' 'the'\n\u003c/pre\u003e\n\u003cp\u003eOptionally, integer \u003cem class=\"firstterm\"\u003epositions\u003c/em\u003e can be attached to lexemes:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003eSELECT 'a:1 fat:2 cat:3 sat:4 on:5 a:6 mat:7 and:8 ate:9 a:10 fat:11 rat:12'::tsvector;\n                                  tsvector\n-------------------------------------------------------------------​------------\n 'a':1,6,10 'and':8 'ate':9 'cat':3 'fat':2,11 'mat':7 'on':5 'rat':12 'sat':4\n\u003c/pre\u003e\n\u003cp\u003eA position normally indicates the source word's location in the document. Positional information can be used for \u003cem class=\"firstterm\"\u003eproximity ranking\u003c/em\u003e. Position values can range from 1 to 16383; larger numbers are silently set to 16383. Duplicate positions for the same lexeme are discarded.\u003c/p\u003e\n\u003cp\u003eLexemes that have positions can further be labeled with a \u003cem class=\"firstterm\"\u003eweight\u003c/em\u003e, which can be \u003ccode class=\"literal\"\u003eA\u003c/code\u003e, \u003ccode class=\"literal\"\u003eB\u003c/code\u003e, \u003ccode class=\"literal\"\u003eC\u003c/code\u003e, or \u003ccode class=\"literal\"\u003eD\u003c/code\u003e. \u003ccode class=\"literal\"\u003eD\u003c/code\u003e is the default and hence is not shown on output:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003eSELECT 'a:1A fat:2B,4C cat:5D'::tsvector;\n          tsvector\n----------------------------\n 'a':1A 'cat':5 'fat':2B,4C\n\u003c/pre\u003e\n\u003cp\u003eWeights are typically used to reflect document structure, for example by marking title words differently from body words. Text search ranking functions can assign different priorities to the different weight markers.\u003c/p\u003e\n\u003cp\u003eIt is important to understand that the \u003ccode class=\"type\"\u003etsvector\u003c/code\u003e type itself does not perform any word normalization; it assumes the words it is given are normalized appropriately for the application. For example,\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003eSELECT 'The Fat Rats'::tsvector;\n      tsvector\n--------------------\n 'Fat' 'Rats' 'The'\n\u003c/pre\u003e\n\u003cp\u003eFor most English-text-searching applications the above words would be considered non-normalized, but \u003ccode class=\"type\"\u003etsvector\u003c/code\u003e doesn't care. Raw document text should usually be passed through \u003ccode class=\"function\"\u003eto_tsvector\u003c/code\u003e to normalize the words appropriately for searching:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003eSELECT to_tsvector('english', 'The Fat Rats');\n   to_tsvector\n-----------------\n 'fat':2 'rat':3\n\u003c/pre\u003e\n\u003cp\u003eAgain, see \u003ca class=\"xref\" href=\"/docs/18/textsearch.html\" title=\"Chapter 12. Full Text Search\"\u003eChapter 12\u003c/a\u003e for more detail.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"sect2\" id=\"DATATYPE-TSQUERY\"\u003e\n\u003cdiv class=\"titlepage\"\u003e\n\u003cdiv\u003e\n\u003cdiv\u003e\n\u003ch3 class=\"title\"\u003e8.11.2. \u003ccode class=\"type\"\u003etsquery\u003c/code\u003e \u003c/h3\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cp\u003eA \u003ccode class=\"type\"\u003etsquery\u003c/code\u003e value stores lexemes that are to be searched for, and can combine them using the Boolean operators \u003ccode class=\"literal\"\u003e\u0026amp;\u003c/code\u003e (AND), \u003ccode class=\"literal\"\u003e|\u003c/code\u003e (OR), and \u003ccode class=\"literal\"\u003e!\u003c/code\u003e (NOT), as well as the phrase search operator \u003ccode class=\"literal\"\u003e\u0026lt;-\u0026gt;\u003c/code\u003e (FOLLOWED BY). There is also a variant \u003ccode class=\"literal\"\u003e\u0026lt;\u003cem class=\"replaceable\"\u003e\u003ccode\u003eN\u003c/code\u003e\u003c/em\u003e\u0026gt;\u003c/code\u003e of the FOLLOWED BY operator, where \u003cem class=\"replaceable\"\u003e\u003ccode\u003eN\u003c/code\u003e\u003c/em\u003e is an integer constant that specifies the distance between the two lexemes being searched for. \u003ccode class=\"literal\"\u003e\u0026lt;-\u0026gt;\u003c/code\u003e is equivalent to \u003ccode class=\"literal\"\u003e\u0026lt;1\u0026gt;\u003c/code\u003e.\u003c/p\u003e\n\u003cp\u003eParentheses can be used to enforce grouping of these operators. In the absence of parentheses, \u003ccode class=\"literal\"\u003e!\u003c/code\u003e (NOT) binds most tightly, \u003ccode class=\"literal\"\u003e\u0026lt;-\u0026gt;\u003c/code\u003e (FOLLOWED BY) next most tightly, then \u003ccode class=\"literal\"\u003e\u0026amp;\u003c/code\u003e (AND), with \u003ccode class=\"literal\"\u003e|\u003c/code\u003e (OR) binding the least tightly.\u003c/p\u003e\n\u003cp\u003eHere are some examples:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003eSELECT 'fat \u0026amp; rat'::tsquery;\n    tsquery\n---------------\n 'fat' \u0026amp; 'rat'\n\nSELECT 'fat \u0026amp; (rat | cat)'::tsquery;\n          tsquery\n---------------------------\n 'fat' \u0026amp; ( 'rat' | 'cat' )\n\nSELECT 'fat \u0026amp; rat \u0026amp; ! cat'::tsquery;\n        tsquery\n------------------------\n 'fat' \u0026amp; 'rat' \u0026amp; !'cat'\n\u003c/pre\u003e\n\u003cp\u003eOptionally, lexemes in a \u003ccode class=\"type\"\u003etsquery\u003c/code\u003e can be labeled with one or more weight letters, which restricts them to match only \u003ccode class=\"type\"\u003etsvector\u003c/code\u003e lexemes with one of those weights:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003eSELECT 'fat:ab \u0026amp; cat'::tsquery;\n    tsquery\n------------------\n 'fat':AB \u0026amp; 'cat'\n\u003c/pre\u003e\n\u003cp\u003eAlso, lexemes in a \u003ccode class=\"type\"\u003etsquery\u003c/code\u003e can be labeled with \u003ccode class=\"literal\"\u003e*\u003c/code\u003e to specify prefix matching:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003eSELECT 'super:*'::tsquery;\n  tsquery\n-----------\n 'super':*\n\u003c/pre\u003e\n\u003cp\u003eThis query will match any word in a \u003ccode class=\"type\"\u003etsvector\u003c/code\u003e that begins with \u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003esuper\u003c/span\u003e”\u003c/span\u003e.\u003c/p\u003e\n\u003cp\u003eQuoting rules for lexemes are the same as described previously for lexemes in \u003ccode class=\"type\"\u003etsvector\u003c/code\u003e; and, as with \u003ccode class=\"type\"\u003etsvector\u003c/code\u003e, any required normalization of words must be done before converting to the \u003ccode class=\"type\"\u003etsquery\u003c/code\u003e type. The \u003ccode class=\"function\"\u003eto_tsquery\u003c/code\u003e function is convenient for performing such normalization:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003eSELECT to_tsquery('Fat:ab \u0026amp; Cats');\n    to_tsquery\n------------------\n 'fat':AB \u0026amp; 'cat'\n\u003c/pre\u003e\n\u003cp\u003eNote that \u003ccode class=\"function\"\u003eto_tsquery\u003c/code\u003e will process prefixes in the same way as other words, which means this comparison returns true:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003eSELECT to_tsvector( 'postgraduate' ) @@ to_tsquery( 'postgres:*' );\n ?column?\n----------\n t\n\u003c/pre\u003e\n\u003cp\u003ebecause \u003ccode class=\"literal\"\u003epostgres\u003c/code\u003e gets stemmed to \u003ccode class=\"literal\"\u003epostgr\u003c/code\u003e:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003eSELECT to_tsvector( 'postgraduate' ), to_tsquery( 'postgres:*' );\n  to_tsvector  | to_tsquery\n---------------+------------\n 'postgradu':1 | 'postgr':*\n\u003c/pre\u003e\n\u003cp\u003ewhich will match the stemmed form of \u003ccode class=\"literal\"\u003epostgraduate\u003c/code\u003e.\u003c/p\u003e\n\u003c/div\u003e\n\u003c/div\u003e","related":[{"label":"pg_type catalog","url":"/wiki/catalog/pg_type/?v=18"},{"label":"pg_cast catalog","url":"/wiki/catalog/pg_cast/?v=18"},{"label":"pg_operator catalog","url":"/wiki/catalog/pg_operator/?v=18"},{"label":"pg_opclass catalog","url":"/wiki/catalog/pg_opclass/?v=18"},{"label":"Arrays","url":"/wiki/type/arrays/?v=18"},{"label":"btree index access method","url":"/wiki/indexam/btree/?v=18"},{"label":"gist index access method","url":"/wiki/indexam/gist/?v=18"}],"sections":[]}},"RequestedLocale":"zh-Hans","Fallback":true,"Versions":["10","11","12","13","14","15","16","17","18","19","20"],"Locales":["en"],"Signatures":null,"Spellings":null,"SQLState":null,"Evidence":null}
