Changeset 779
- Timestamp:
- 10/30/07 19:55:05 (1 year ago)
- Files:
-
- traduc/trunk/manuel/backup.xml (modified) (1 diff)
- traduc/trunk/manuel/config.xml (modified) (1 diff)
- traduc/trunk/manuel/datatype.xml (modified) (3 diffs)
- traduc/trunk/manuel/external-projects.xml (modified) (3 diffs)
- traduc/trunk/manuel/func.xml (modified) (7 diffs)
- traduc/trunk/manuel/maintenance.xml (modified) (5 diffs)
- traduc/trunk/manuel/perform.xml (modified) (5 diffs)
- traduc/trunk/manuel/plpgsql.xml (modified) (1 diff)
- traduc/trunk/manuel/ref/alter_sequence.xml (modified) (2 diffs)
- traduc/trunk/manuel/ref/alter_tsdictionary.xml (modified) (11 diffs)
- traduc/trunk/manuel/ref/analyze.xml (modified) (3 diffs)
- traduc/trunk/manuel/ref/declare.xml (modified) (2 diffs)
- traduc/trunk/manuel/ref/fetch.xml (modified) (1 diff)
- traduc/trunk/manuel/ref/vacuum.xml (modified) (1 diff)
- traduc/trunk/manuel/release.xml (modified) (1 diff)
- traduc/trunk/manuel/textsearch.xml (modified) (98 diffs)
- traduc/trunk/manuel/version.xml (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
traduc/trunk/manuel/backup.xml
r747 r779 1892 1892 1893 1893 <para> 1894 Il est aussi possible d'utiliser des outils de réplication comme 1895 <productname>Slony</productname> pour créer un serveur esclave avec la 1896 nouvelle version de <productname>PostgreSQL</productname>. L'esclave peut 1897 se trouver sur le même ordinateur ou sur un autre. Une fois qu'il est 1898 synchronisé avec le serveur maître (utilisant l'ancienne version de 1899 <productname>PostgreSQL</productname>), vous pouvez basculer maître et 1900 esclave pour que l'esclave devienne le maître, puis arrêter l'ancien 1901 serveur. Ce basculement se faire en quelques secondes pour une mise à 1902 jour. 1903 </para> 1904 1905 <para> 1894 1906 En pratique, on souhaite souvent tester son application sur le 1895 1907 nouveau serveur avant de basculer définitivement. C'est une autre raison traduc/trunk/manuel/config.xml
r762 r779 2468 2468 journaux applicatifs au format CSV. 2469 2469 </para> 2470 2471 <note> 2472 <para> 2473 Sur la plupart des Unix systèmes, vous aurez besoin de modifier la 2474 configuration du démon <application>syslog</application> pour utiliser 2475 l'option <systemitem>syslog</systemitem> de 2476 <varname>log_destination</varname>. <productname>PostgreSQL</productname> 2477 peut tracer dans certaines les <application>syslog</application> 2478 <literal>LOCAL0</literal> à <literal>LOCAL7</literal> (voir <xref 2479 linkend="guc-syslog-facility"/>) mais la configuration par défaut de 2480 <application>syslog</application> sur la plupart des plateformes 2481 ignorera de tels messages. Vous aurez donc besoin d'ajouter quelque 2482 chose comme : 2483 <programlisting> 2484 local0.* /var/log/postgresql 2485 </programlisting> 2486 dans le fichier de configuration de <application>syslog</application> 2487 pour obtenir ce type de journalisation. 2488 </para> 2489 </note> 2470 2490 </listitem> 2471 2491 </varlistentry> traduc/trunk/manuel/datatype.xml
r756 r779 253 253 <entry></entry> 254 254 <entry>document pour la recherche plein texte</entry> 255 </row> 256 257 <row> 258 <entry><type>txid_snapshot</type></entry> 259 <entry></entry> 260 <entry>image de l'identifiant de transaction au niveau utilisateur</entry> 255 261 </row> 256 262 … … 3323 3329 </sect1> 3324 3330 3331 <sect1 id="datatype-textsearch"> 3332 <title>Text Search Types</title> 3333 3334 <indexterm zone="datatype-textsearch"> 3335 <primary>full text search</primary> 3336 <secondary>data types</secondary> 3337 </indexterm> 3338 3339 <indexterm zone="datatype-textsearch"> 3340 <primary>text search</primary> 3341 <secondary>data types</secondary> 3342 </indexterm> 3343 3344 <para> 3345 <productname>PostgreSQL</productname> provides two data types that 3346 are designed to support full text search, which is the activity of 3347 searching through a collection of natural-language <firstterm>documents</firstterm> 3348 to locate those that best match a <firstterm>query</firstterm>. 3349 The <type>tsvector</type> type represents a document in a form suited 3350 for text search, while the <type>tsquery</type> type similarly represents 3351 a query. 3352 <xref linkend="textsearch"/> provides a detailed explanation of this 3353 facility, and <xref linkend="functions-textsearch"/> summarizes the 3354 related functions and operators. 3355 </para> 3356 3357 <sect2 id="datatype-tsvector"> 3358 <title><type>tsvector</type></title> 3359 3360 <indexterm> 3361 <primary>tsvector (data type)</primary> 3362 </indexterm> 3363 3364 <para> 3365 A <type>tsvector</type> value is a sorted list of distinct 3366 <firstterm>lexemes</firstterm>, which are words that have been 3367 <firstterm>normalized</firstterm> to make different variants of the same word look 3368 alike (see <xref linkend="textsearch"/> for details). Sorting and 3369 duplicate-elimination are done automatically during input, as shown in 3370 this example: 3371 3372 <programlisting> 3373 SELECT 'a fat cat sat on a mat and ate a fat rat'::tsvector; 3374 tsvector 3375 ---------------------------------------------------- 3376 'a' 'on' 'and' 'ate' 'cat' 'fat' 'mat' 'rat' 'sat' 3377 </programlisting> 3378 3379 (As the example shows, the sorting is first by length and then 3380 alphabetically, but that detail is seldom important.) To represent 3381 lexemes containing whitespace, surround them with quotes: 3382 3383 <programlisting> 3384 SELECT $$the lexeme ' ' contains spaces$$::tsvector; 3385 tsvector 3386 ------------------------------------------- 3387 'the' ' ' 'lexeme' 'spaces' 'contains' 3388 </programlisting> 3389 3390 (We use dollar-quoted string literals in this example and the next one, 3391 to avoid confusing matters by having to double quote marks within the 3392 literals.) Embedded quotes can be handled by doubling them: 3393 3394 <programlisting> 3395 SELECT $$the lexeme 'Joe''s' contains a quote$$::tsvector; 3396 tsvector 3397 ------------------------------------------------ 3398 'a' 'the' 'Joe''s' 'quote' 'lexeme' 'contains' 3399 </programlisting> 3400 3401 Optionally, integer <firstterm>position(s)</firstterm> 3402 can be attached to any or all of the lexemes: 3403 3404 <programlisting> 3405 SELECT '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; 3406 tsvector 3407 ------------------------------------------------------------------------------- 3408 'a':1,6,10 'on':5 'and':8 'ate':9 'cat':3 'fat':2,11 'mat':7 'rat':12 'sat':4 3409 </programlisting> 3410 3411 A position normally indicates the source word's location in the 3412 document. Positional information can be used for 3413 <firstterm>proximity ranking</firstterm>. Position values can 3414 range from 1 to 16383; larger numbers are silently clamped to 16383. 3415 Duplicate position entries are discarded. 3416 </para> 3417 3418 <para> 3419 Lexemes that have positions can further be labeled with a 3420 <firstterm>weight</firstterm>, which can be <literal>A</literal>, 3421 <literal>B</literal>, <literal>C</literal>, or <literal>D</literal>. 3422 <literal>D</literal> is the default and hence is not shown on output: 3423 3424 <programlisting> 3425 SELECT 'a:1A fat:2B,4C cat:5D'::tsvector; 3426 tsvector 3427 ---------------------------- 3428 'a':1A 'cat':5 'fat':2B,4C 3429 </programlisting> 3430 3431 Weights are typically used to reflect document structure, for example 3432 by marking title words differently from body words. Text search 3433 ranking functions can assign different priorities to the different 3434 weight markers. 3435 </para> 3436 3437 <para> 3438 It is important to understand that the 3439 <type>tsvector</type> type itself does not perform any normalization; 3440 it assumes that the words it is given are normalized appropriately 3441 for the application. For example, 3442 3443 <programlisting> 3444 select 'The Fat Rats'::tsvector; 3445 tsvector 3446 -------------------- 3447 'Fat' 'The' 'Rats' 3448 </programlisting> 3449 3450 For most English-text-searching applications the above words would 3451 be considered non-normalized, but <type>tsvector</type> doesn't care. 3452 Raw document text should usually be passed through 3453 <function>to_tsvector</function> to normalize the words appropriately 3454 for searching: 3455 3456 <programlisting> 3457 SELECT to_tsvector('english', 'The Fat Rats'); 3458 to_tsvector 3459 ----------------- 3460 'fat':2 'rat':3 3461 </programlisting> 3462 3463 Again, see <xref linkend="textsearch"/> for more detail. 3464 </para> 3465 3466 </sect2> 3467 3468 <sect2 id="datatype-tsquery"> 3469 <title><type>tsquery</type></title> 3470 3471 <indexterm> 3472 <primary>tsquery (data type)</primary> 3473 </indexterm> 3474 3475 <para> 3476 A <type>tsquery</type> value stores lexemes that are to be 3477 searched for, and combines them using the boolean operators 3478 <literal>&</literal> (AND), <literal>|</literal> (OR), and 3479 <literal>!</literal> (NOT). Parentheses can be used to enforce grouping 3480 of the operators: 3481 3482 <programlisting> 3483 SELECT 'fat & rat'::tsquery; 3484 tsquery 3485 --------------- 3486 'fat' & 'rat' 3487 3488 SELECT 'fat & (rat | cat)'::tsquery; 3489 tsquery 3490 --------------------------- 3491 'fat' & ( 'rat' | 'cat' ) 3492 3493 SELECT 'fat & rat & ! cat'::tsquery; 3494 tsquery 3495 ------------------------ 3496 'fat' & 'rat' & !'cat' 3497 </programlisting> 3498 3499 In the absence of parentheses, <literal>!</literal> (NOT) binds most tightly, 3500 and <literal>&</literal> (AND) binds more tightly than 3501 <literal>|</literal> (OR). 3502 </para> 3503 3504 <para> 3505 Optionally, lexemes in a <type>tsquery</type> can be labeled with 3506 one or more weight letters, which restricts them to match only 3507 <type>tsvector</type> lexemes with one of those weights: 3508 3509 <programlisting> 3510 SELECT 'fat:ab & cat'::tsquery; 3511 tsquery 3512 ------------------ 3513 'fat':AB & 'cat' 3514 </programlisting> 3515 </para> 3516 3517 <para> 3518 Quoting rules for lexemes are the same as described above for 3519 lexemes in <type>tsvector</type>; and, as with <type>tsvector</type>, 3520 any required normalization of words must be done before putting 3521 them into the <type>tsquery</type> type. The <function>to_tsquery</function> 3522 function is convenient for performing such normalization: 3523 3524 <programlisting> 3525 SELECT to_tsquery('Fat:ab & Cats'); 3526 to_tsquery 3527 ------------------ 3528 'fat':AB & 'cat' 3529 </programlisting> 3530 </para> 3531 3532 </sect2> 3533 3534 </sect1> 3535 3325 3536 <sect1 id="datatype-uuid"> 3326 3537 <title>Type <acronym>UUID</acronym></title> … … 3375 3586 bibliothèques appelées par une fonction serveur. 3376 3587 </para> 3377 </sect1>3378 3379 <sect1 id="datatype-textsearch">3380 <title>Recherche plein texte</title>3381 3382 <variablelist>3383 3384 <varlistentry>3385 <term><firstterm>tsvector</firstterm></term>3386 <listitem>3387 3388 <para>3389 <type>tsvector</type>3390 <indexterm><primary>tsvector</primary></indexterm> est un type de données3391 qui représente un document et est optimisé pour la recherche plein texte.3392 Dans le cas le plus simple, <type>tsvector</type> est une liste triée de3393 lexemes, donc même sans index, les recherches plein texte s'exécutent3394 plus rapidement que les opérations standards <literal>~</literal> et3395 <literal>LIKE</literal> :3396 3397 <programlisting>3398 SELECT 'a fat cat sat on a mat and ate a fat rat'::tsvector;3399 tsvector3400 ----------------------------------------------------3401 'a' 'on' 'and' 'ate' 'cat' 'fat' 'mat' 'rat' 'sat'3402 </programlisting>3403 3404 Notice, that <literal>space</literal> is also a lexeme:3405 3406 <programlisting>3407 SELECT 'space '' '' is a lexeme'::tsvector;3408 tsvector3409 ----------------------------------3410 'a' 'is' ' ' 'space' 'lexeme'3411 </programlisting>3412 3413 En option, chaque lexeme peut avoir des informations de positionnement3414 à utiliser pour améliorer le <varname>score</varname> :3415 3416 <programlisting>3417 SELECT '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;3418 tsvector3419 -------------------------------------------------------------------------------3420 'a':1,6,10 'on':5 'and':8 'ate':9 'cat':3 'fat':2,11 'mat':7 'rat':12 'sat':43421 </programlisting>3422 3423 Chaque position de lexeme peut aussi utiliser un label <literal>A</literal>,3424 <literal>B</literal>, <literal>C</literal>, <literal>D</literal>,3425 avec <literal>D</literal> comme valeur par défaut. Ces labels sont3426 utilisées pour grouper les lexemes de différentes3427 <emphasis>importance</emphasis> ou de <emphasis>scores</emphasis>3428 différents, par exemple pour refléter la structure du document. Des3429 valeurs réelles peuvent être affectées au moment de la recherche et3430 utilisées lors du calcul du score du document. Ceci est très utile pour3431 contrôler les résultats des recherches.3432 </para>3433 3434 <para>3435 L'opérateur de concaténation operator, c'est-à-dire <literal>tsvector ||3436 tsvector</literal>, peut construire un document à partir de différentes3437 sources. L'ordre est important si <type>tsvector</type> contient des3438 informations de position. Bien sûr, il est aussi possible de construire3439 un document en utilisant différentes tables :3440 3441 <programlisting>3442 SELECT 'fat:1 cat:2'::tsvector || 'fat:1 rat:2'::tsvector;3443 ?column?3444 ---------------------------3445 'cat':2 'fat':1,3 'rat':43446 3447 SELECT 'fat:1 rat:2'::tsvector || 'fat:1 cat:2'::tsvector;3448 ?column?3449 ---------------------------3450 'cat':4 'fat':1,3 'rat':23451 </programlisting>3452 3453 </para>3454 3455 </listitem>3456 3457 </varlistentry>3458 3459 <varlistentry>3460 <term><firstterm>tsquery</firstterm></term>3461 <listitem>3462 3463 <para>3464 <type>tsquery</type>3465 <indexterm><primary>tsquery</primary></indexterm> est un type de données3466 pour les requêtes de recherche plein texte. Ce type supporte les3467 opérateurs booléens <literal>&</literal> (AND), <literal>|</literal>3468 (OR) et les parenthèses. Un <type>tsquery</type> consiste en des lexemes3469 (quelque fois avec des labels) entrecoupés d'opérateurs booléens :3470 3471 <programlisting>3472 SELECT 'fat & cat'::tsquery;3473 tsquery3474 ---------------3475 'fat' & 'cat'3476 SELECT 'fat:ab & cat'::tsquery;3477 tsquery3478 ------------------3479 'fat':AB & 'cat'3480 </programlisting>3481 3482 Les labels sont utilisés pour restreindre la région de la recherche, ce qui3483 permet le développement de différents moteurs de recherche utilisant le3484 même index plein texte.3485 </para>3486 3487 <para>3488 <type>tsqueries</type> peut être concaténé en utilisant les opérateurs3489 <literal>&&</literal> (AND) et <literal>||</literal> (OR) :3490 3491 <programlisting>3492 SELECT 'a & b'::tsquery && 'c | d'::tsquery;3493 ?column?3494 ---------------------------3495 'a' & 'b' & ( 'c' | 'd' )3496 3497 SELECT 'a & b'::tsquery || 'c|d'::tsquery;3498 ?column?3499 ---------------------------3500 'a' & 'b' | ( 'c' | 'd' )3501 </programlisting>3502 3503 </para>3504 </listitem>3505 </varlistentry>3506 </variablelist>3507 3508 3588 </sect1> 3509 3589 traduc/trunk/manuel/external-projects.xml
r655 r779 109 109 <entry>C++</entry> 110 110 <entry>Interface C++, nouveau style</entry> 111 <entry><ulink url="http:// thaiopensource.org/development/libpqxx/">http://thaiopensource.org/development/libpqxx/</ulink></entry>111 <entry><ulink url="http://pqxx.org/">http://pqxx.org/</ulink></entry> 112 112 </row> 113 113 … … 123 123 <entry>.NET</entry> 124 124 <entry>Fournisseur de données .NET</entry> 125 <entry><ulink url="http:// pgfoundry.org/projects/npgsql/">http://pgfoundry.org/projects/npgsql/</ulink></entry>125 <entry><ulink url="http://npgsql.projects.postgresql.org/">http://npgsql.projects.postgresql.org/</ulink></entry> 126 126 </row> 127 127 … … 144 144 <entry>ODBC</entry> 145 145 <entry>Pilote ODBC le plus communément utilisé </entry> 146 <entry><ulink url="http:// odbc.postgresql.org/">http://odbc.postgresql.org/</ulink></entry>146 <entry><ulink url="http://psqlodbc.projects.postgresql.org/">http://psqlodbc.projects.postgresql.org/</ulink></entry> 147 147 </row> 148 148 traduc/trunk/manuel/func.xml
r756 r779 7928 7928 7929 7929 <sect1 id="functions-textsearch"> 7930 <title>Full Text Search Functions and Operators</title> 7930 <title>Text Search Functions and Operators</title> 7931 7932 <indexterm zone="datatype-textsearch"> 7933 <primary>full text search</primary> 7934 <secondary>functions and operators</secondary> 7935 </indexterm> 7936 7937 <indexterm zone="datatype-textsearch"> 7938 <primary>text search</primary> 7939 <secondary>functions and operators</secondary> 7940 </indexterm> 7931 7941 7932 7942 <para> 7933 This section outlines all the functions and operators that are available 7934 for full text searching. 7943 <xref linkend="textsearch-operators-table"/>, 7944 <xref linkend="textsearch-functions-table"/> and 7945 <xref linkend="textsearch-functions-debug-table"/> 7946 summarize the functions and operators that are provided 7947 for full text searching. See <xref linkend="textsearch"/> for a detailed 7948 explanation of <productname>PostgreSQL</productname>'s text search 7949 facility. 7935 7950 </para> 7936 7951 7952 <table id="textsearch-operators-table"> 7953 <title>Text Search Operators</title> 7954 <tgroup cols="4"> 7955 <thead> 7956 <row> 7957 <entry>Operator</entry> 7958 <entry>Description</entry> 7959 <entry>Example</entry> 7960 <entry>Result</entry> 7961 </row> 7962 </thead> 7963 <tbody> 7964 <row> 7965 <entry> <literal>@@</literal> </entry> 7966 <entry><type>tsvector</type> matches <type>tsquery</type> ?</entry> 7967 <entry><literal>to_tsvector('fat cats ate rats') @@ to_tsquery('cat & rat')</literal></entry> 7968 <entry><literal>t</literal></entry> 7969 </row> 7970 <row> 7971 <entry> <literal>@@@</literal> </entry> 7972 <entry>same as <literal>@@</literal>, but see <xref linkend="textsearch-indexes"/></entry> 7973 <entry><literal>to_tsvector('fat cats ate rats') @@@ to_tsquery('cat & rat')</literal></entry> 7974 <entry><literal>t</literal></entry> 7975 </row> 7976 <row> 7977 <entry> <literal>||</literal> </entry> 7978 <entry>concatenate <type>tsvector</type>s</entry> 7979 <entry><literal>'a:1 b:2'::tsvector || 'c:1 d:2 b:3'::tsvector</literal></entry> 7980 <entry><literal>'a':1 'b':2,5 'c':3 'd':4</literal></entry> 7981 </row> 7982 <row> 7983 <entry> <literal>&&</literal> </entry> 7984 <entry>AND <type>tsquery</type>s together</entry> 7985 <entry><literal>'fat | rat'::tsquery && 'cat'::tsquery</literal></entry> 7986 <entry><literal>( 'fat' | 'rat' ) & 'cat'</literal></entry> 7987 </row> 7988 <row> 7989 <entry> <literal>||</literal> </entry> 7990 <entry>OR <type>tsquery</type>s together</entry> 7991 <entry><literal>'fat | rat'::tsquery || 'cat'::tsquery</literal></entry> 7992 <entry><literal>( 'fat' | 'rat' ) | 'cat'</literal></entry> 7993 </row> 7994 <row> 7995 <entry> <literal>!!</literal> </entry> 7996 <entry>negate a <type>tsquery</type></entry> 7997 <entry><literal>!! 'cat'::tsquery</literal></entry> 7998 <entry><literal>!'cat'</literal></entry> 7999 </row> 8000 <row> 8001 <entry> <literal>@></literal> </entry> 8002 <entry><type>tsquery</type> contains another ?</entry> 8003 <entry><literal>'cat'::tsquery @> 'cat & rat'::tsquery</literal></entry> 8004 <entry><literal>f</literal></entry> 8005 </row> 8006 <row> 8007 <entry> <literal><@</literal> </entry> 8008 <entry><type>tsquery</type> is contained in ?</entry> 8009 <entry><literal>'cat'::tsquery <@ 'cat & rat'::tsquery</literal></entry> 8010 <entry><literal>t</literal></entry> 8011 </row> 8012 </tbody> 8013 </tgroup> 8014 </table> 8015 8016 <note> 8017 <para> 8018 The <type>tsquery</type> containment operators consider only the lexemes 8019 listed in the two queries, ignoring the combining operators. 8020 </para> 8021 </note> 8022 8023 <para> 8024 In addition to the operators shown in the table, the ordinary B-tree 8025 comparison operators (<literal>=</literal>, <literal><</literal>, etc) are defined 8026 for types <type>tsvector</type> and <type>tsquery</type>. These are not very 8027 useful for text searching but allow, for example, unique indexes to be 8028 built on columns of these types. 8029 </para> 8030 8031 <table id="textsearch-functions-table"> 8032 <title>Text Search Functions</title> 8033 <tgroup cols="5"> 8034 <thead> 8035 <row> 8036 <entry>Function</entry> 8037 <entry>Return Type</entry> 8038 <entry>Description</entry> 8039 <entry>Example</entry> 8040 <entry>Result</entry> 8041 </row> 8042 </thead> 8043 <tbody> 8044 <row> 8045 <entry><literal><function>to_tsvector</function>(<optional> <replaceable class="PARAMETER">config</replaceable> <type>regconfig</type> , </optional> <replaceable class="PARAMETER">document</replaceable> <type>text</type>)</literal></entry> 8046 <entry><type>tsvector</type></entry> 8047 <entry>reduce document text to <type>tsvector</type></entry> 8048 <entry><literal>to_tsvector('english', 'The Fat Rats')</literal></entry> 8049 <entry><literal>'fat':2 'rat':3</literal></entry> 8050 </row> 8051 <row> 8052 <entry><literal><function>length</function>(<type>tsvector</type>)</literal></entry> 8053 <entry><type>integer</type></entry> 8054 <entry>number of lexemes in <type>tsvector</type></entry> 8055 <entry><literal>length('fat:2,4 cat:3 rat:5A'::tsvector)</literal></entry> 8056 <entry><literal>3</literal></entry> 8057 </row> 8058 <row> 8059 <entry><literal><function>setweight</function>(<type>tsvector</type>, <type>"char"</type>)</literal></entry> 8060 <entry><type>tsvector</type></entry> 8061 <entry>assign weight to each element of <type>tsvector</type></entry> 8062 <entry><literal>setweight('fat:2,4 cat:3 rat:5B'::tsvector, 'A')</literal></entry> 8063 <entry><literal>'cat':3A 'fat':2A,4A 'rat':5A</literal></entry> 8064 </row> 8065 <row> 8066 <entry><literal><function>strip</function>(<type>tsvector</type>)</literal></entry> 8067 <entry><type>tsvector</type></entry> 8068 <entry>remove positions and weights from <type>tsvector</type></entry> 8069 <entry><literal>strip('fat:2,4 cat:3 rat:5A'::tsvector)</literal></entry> 8070 <entry><literal>'cat' 'fat' 'rat'</literal></entry> 8071 </row> 8072 <row> 8073 <entry><literal><function>to_tsquery</function>(<optional> <replaceable class="PARAMETER">config</replaceable> <type>regconfig</type> , </optional> <replaceable class="PARAMETER">query</replaceable> <type>text</type>)</literal></entry> 8074 <entry><type>tsquery</type></entry> 8075 <entry>normalize words and convert to <type>tsquery</type></entry> 8076 <entry><literal>to_tsquery('english', 'The & Fat & Rats')</literal></entry> 8077 <entry><literal>'fat' & 'rat'</literal></entry> 8078 </row> 8079 <row> 8080 <entry><literal><function>plainto_tsquery</function>(<optional> <replaceable class="PARAMETER">config</replaceable> <type>regconfig</type> , </optional> <replaceable class="PARAMETER">query</replaceable> <type>text</type>)</literal></entry> 8081 <entry><type>tsquery</type></entry> 8082 <entry>produce <type>tsquery</type> ignoring punctuation</entry> 8083 <entry><literal>plainto_tsquery('english', 'The Fat Rats')</literal></entry> 8084 <entry><literal>'fat' & 'rat'</literal></entry> 8085 </row> 8086 <row> 8087 <entry><literal><function>numnode</function>(<type>tsquery</type>)</literal></entry> 8088 <entry><type>integer</type></entry> 8089 <entry>number of lexemes plus operators in <type>tsquery</type></entry> 8090 <entry><literal> numnode('(fat & rat) | cat'::tsquery)</literal></entry> 8091 <entry><literal>5</literal></entry> 8092 </row> 8093 <row> 8094 <entry><literal><function>querytree</function>(<replaceable class="PARAMETER">query</replaceable> <type>tsquery</type>)</literal></entry> 8095 <entry><type>text</type></entry> 8096 <entry>get indexable part of a <type>tsquery</type></entry> 8097 <entry><literal>querytree('foo & ! bar'::tsquery)</literal></entry> 8098 <entry><literal>'foo'</literal></entry> 8099 </row> 8100 <row> 8101 <entry><literal><function>ts_rank</function>(<optional> <replaceable class="PARAMETER">weights</replaceable> <type>float4[]</type>, </optional> <replaceable class="PARAMETER">vector</replaceable> <type>tsvector</type>, <replaceable class="PARAMETER">query</replaceable> <type>tsquery</type> <optional>, <replaceable class="PARAMETER">normalization</replaceable> <type>integer</type> </optional>)</literal></entry> 8102 <entry><type>float4</type></entry> 8103 <entry>rank document for query</entry> 8104 <entry><literal>ts_rank(textsearch, query)</literal></entry> 8105 <entry><literal>0.818</literal></entry> 8106 </row> 8107 <row> 8108 <entry><literal><function>ts_rank_cd</function>(<optional> <replaceable class="PARAMETER">weights</replaceable> <type>float4[]</type>, </optional> <replaceable class="PARAMETER">vector</replaceable> <type>tsvector</type>, <replaceable class="PARAMETER">query</replaceable> <type>tsquery</type> <optional>, <replaceable class="PARAMETER">normalization</replaceable> <type>integer</type> </optional>)</literal></entry> 8109 <entry><type>float4</type></entry> 8110 <entry>rank document for query using cover density</entry> 8111 <entry><literal>ts_rank_cd('{0.1, 0.2, 0.4, 1.0}', textsearch, query)</literal></entry> 8112 <entry><literal>2.01317</literal></entry> 8113 </row> 8114 <row> 8115 <entry><literal><function>ts_headline</function>(<optional> <replaceable class="PARAMETER">config</replaceable> <type>regconfig</type>, </optional> <replaceable class="PARAMETER">document</replaceable> <type>text</type>, <replaceable class="PARAMETER">query</replaceable> <type>tsquery</type> <optional>, <replaceable class="PARAMETER">options</replaceable> <type>text</type> </optional>)</literal></entry> 8116 <entry><type>text</type></entry> 8117 <entry>display a query match</entry> 8118 <entry><literal>ts_headline('x y z', 'z'::tsquery)</literal></entry> 8119 <entry><literal>x y <b>z</b></literal></entry> 8120 </row> 8121 <row> 8122 <entry><literal><function>ts_rewrite</function>(<replaceable class="PARAMETER">query</replaceable> <type>tsquery</type>, <replaceable class="PARAMETER">target</replaceable> <type>tsquery</type>, <replaceable class="PARAMETER">substitute</replaceable> <type>tsquery</type>)</literal></entry> 8123 <entry><type>tsquery</type></entry> 8124 <entry>replace target with substitute within query</entry> 8125 <entry><literal>ts_rewrite('a & b'::tsquery, 'a'::tsquery, 'foo|bar'::tsquery)</literal></entry> 8126 <entry><literal>'b' & ( 'foo' | 'bar' )</literal></entry> 8127 </row> 8128 <row> 8129 <entry><literal><function>ts_rewrite</function>(<replaceable class="PARAMETER">query</replaceable> <type>tsquery</type>, <replaceable class="PARAMETER">select</replaceable> <type>text</type>)</literal></entry> 8130 <entry><type>tsquery</type></entry> 8131 <entry>replace using targets and substitutes from a <command>SELECT</command> command</entry> 8132 <entry><literal>SELECT ts_rewrite('a & b'::tsquery, 'SELECT t,s FROM aliases')</literal></entry> 8133 <entry><literal>'b' & ( 'foo' | 'bar' )</literal></entry> 8134 </row> 8135 <row> 8136 <entry><literal><function>get_current_ts_config</function>()</literal></entry> 8137 <entry><type>regconfig</type></entry> 8138 <entry>get default text search configuration</entry> 8139 <entry><literal>get_current_ts_config()</literal></entry> 8140 <entry><literal>english</literal></entry> 8141 </row> 8142 <row> 8143 <entry><literal><function>tsvector_update_trigger</function>()</literal></entry> 8144 <entry><type>trigger</type></entry> 8145 <entry>trigger function for automatic <type>tsvector</type> column update</entry> 8146 <entry><literal>CREATE TRIGGER ... tsvector_update_trigger(tsvcol, 'pg_catalog.swedish', title, body)</literal></entry> 8147 <entry><literal></literal></entry> 8148 </row> 8149 <row> 8150 <entry><literal><function>tsvector_update_trigger_column</function>()</literal></entry> 8151 <entry><type>trigger</type></entry> 8152 <entry>trigger function for automatic <type>tsvector</type> column update</entry> 8153 <entry><literal>CREATE TRIGGER ... tsvector_update_trigger_column(tsvcol, configcol, title, body)</literal></entry> 8154 <entry><literal></literal></entry> 8155 <entry><literal></literal></entry> 8156 </row> 8157 </tbody> 8158 </tgroup> 8159 </table> 8160 8161 <note> 8162 <para> 8163 All the text search functions that accept an optional <type>regconfig</type> 8164 argument will use the configuration specified by 8165 <xref linkend="guc-default-text-search-config"/> 8166 when that argument is omitted. 8167 </para> 8168 </note> 8169 7937 8170 <para> 7938 Full text search vectors and queries both use lexemes, but for different 7939 purposes. A <type>tsvector</type> represents the lexemes (tokens) parsed 7940 out of a document, with an optional position. A <type>tsquery</type> 7941 specifies a boolean condition using lexemes. 8171 The functions in 8172 <xref linkend="textsearch-functions-debug-table"/> 8173 are listed separately because they are not usually used in everyday text 8174 searching operations. They are helpful for development and debugging 8175 of new text search configurations. 7942 8176 </para> 7943 8177 7944 <para> 7945 All of the following functions that accept a configuration argument can 7946 use a textual configuration name to select a configuration. If the option 7947 is omitted the configuration specified by 7948 <varname>default_text_search_config</varname> is used. For more information on 7949 configuration, see <xref linkend="textsearch-tables-configuration"/>. 7950 </para> 7951 7952 <sect2 id="functions-textsearch-search-operator"> 7953 <title>Search</title> 7954 7955 <para>The operator <literal>@@</literal> is used to perform full text 7956 searches: 7957 </para> 7958 7959 <variablelist> 7960 7961 <varlistentry> 7962 <term> 7963 <synopsis> 7964 <!-- why allow such combinations? --> 7965 TSVECTOR @@ TSQUERY 7966 TSQUERY @@ TSVECTOR 7967 </synopsis> 7968 </term> 7969 7970 <listitem> 7971 <indexterm> 7972 <primary>TSVECTOR @@ TSQUERY</primary> 7973 </indexterm> 7974 <para> 7975 Returns <literal>true</literal> if <literal>TSQUERY</literal> is contained 7976 in <literal>TSVECTOR</literal>, and <literal>false</literal> if not: 7977 7978 <programlisting> 7979 SELECT 'a fat cat sat on a mat and ate a fat rat'::tsvector @@ 'cat & rat'::tsquery; 7980 ?column? 7981 ---------- 7982 t 7983 7984 SELECT 'a fat cat sat on a mat and ate a fat rat'::tsvector @@ 'fat & cow'::tsquery; 7985 ?column? 7986 ---------- 7987 f 7988 </programlisting> 7989 </para> 7990 7991 </listitem> 7992 </varlistentry> 7993 7994 <varlistentry> 7995 <term> 7996 <synopsis> 7997 text @@ tsquery 7998 </synopsis> 7999 </term> 8000 8001 <listitem> 8002 <indexterm> 8003 <primary>TEXT @@ TSQUERY</primary> 8004 </indexterm> 8005 <para> 8006 Returns <literal>true</literal> if <literal>TSQUERY</literal> is contained 8007 in <literal>TEXT</literal>, and <literal>false</literal> if not: 8008 8009 <programlisting> 8010 SELECT 'a fat cat sat on a mat and ate a fat rat'::text @@ 'cat & rat'::tsquery; 8011 ?column? 8012 ---------- 8013 t 8014 8015 SELECT 'a fat cat sat on a mat and ate a fat rat'::text @@ 'cat & cow'::tsquery; 8016 ?column? 8017 ---------- 8018 f 8019 </programlisting> 8020 </para> 8021 </listitem> 8022 </varlistentry> 8023 8024 <varlistentry> 8025 <term> 8026 <synopsis> 8027 <!-- this is very confusing because there is no rule suggesting which is 8028 first. --> 8029 text @@ text 8030 </synopsis> 8031 </term> 8032 8033 <listitem> 8034 <indexterm> 8035 <primary>TEXT @@ TEXT</primary> 8036 </indexterm> 8037 <para> 8038 Returns <literal>true</literal> if the right 8039 argument (the query) is contained in the left argument, and 8040 <literal>false</literal> otherwise: 8041 8042 <programlisting> 8043 SELECT 'a fat cat sat on a mat and ate a fat rat' @@ 'cat rat'; 8044 ?column? 8045 ---------- 8046 t 8047 8048 SELECT 'a fat cat sat on a mat and ate a fat rat' @@ 'cat cow'; 8049 ?column? 8050 ---------- 8051 f 8052 </programlisting> 8053 </para> 8054 8055 </listitem> 8056 </varlistentry> 8057 8058 </variablelist> 8059 8060 <para> 8061 For index support of full text operators consult <xref linkend="textsearch-indexes"/>. 8062 </para> 8063 8064 </sect2> 8065 8066 <sect2 id="functions-textsearch-tsvector"> 8067 <title>tsvector</title> 8068 8069 <variablelist> 8070 8071 <varlistentry> 8072 <term> 8073 <synopsis> 8074 to_tsvector(<optional><replaceable class="parameter">config_name</replaceable></optional>, <replaceable class="parameter">document</replaceable> TEXT) returns TSVECTOR 8075 </synopsis> 8076 </term> 8077 8078 <listitem> 8079 <indexterm> 8080 <primary>to_tsvector</primary> 8081 </indexterm> 8082 <para> 8083 Parses a document into tokens, reduces the tokens to lexemes, and returns a 8084 <type>tsvector</type> which lists the lexemes together with their positions in the document 8085 in lexicographic order. 8086 </para> 8087 8088 </listitem> 8089 </varlistentry> 8090 8091 <varlistentry> 8092 <term> 8093 <synopsis> 8094 strip(<replaceable class="parameter">vector</replaceable> TSVECTOR) returns TSVECTOR 8095 </synopsis> 8096 </term> 8097 8098 <listitem> 8099 <indexterm> 8100 <primary>strip</primary> 8101 </indexterm> 8102 <para> 8103 Returns a vector which lists the same lexemes as the given vector, but 8104 which lacks any information about where in the document each lexeme 8105 appeared. While the returned vector is useless for relevance ranking it 8106 will usually be much smaller. 8107 </para> 8108 </listitem> 8109 8110 </varlistentry> 8111 8112 <varlistentry> 8113 <term> 8114 <synopsis> 8115 setweight(<replaceable class="parameter">vector</replaceable> TSVECTOR, <replaceable class="parameter">letter</replaceable>) returns TSVECTOR 8116 </synopsis> 8117 </term> 8118 8119 <listitem> 8120 <indexterm> 8121 <primary>setweight</primary> 8122 </indexterm> 8123 <para> 8124 This function returns a copy of the input vector in which every location 8125 has been labeled with either the letter <literal>A</literal>, 8126 <literal>B</literal>, or <literal>C</literal>, or the default label 8127 <literal>D</literal> (which is the default for new vectors 8128 and as such is usually not displayed). These labels are retained 8129 when vectors are concatenated, allowing words from different parts of a 8130 document to be weighted differently by ranking functions. 8131 </para> 8132 </listitem> 8133 </varlistentry> 8134 8135 <varlistentry> 8136 <term> 8137 <synopsis> 8138 <replaceable class="parameter">vector1</replaceable> || <replaceable class="parameter">vector2</replaceable> 8139 tsvector_concat(<replaceable class="parameter">vector1</replaceable> TSVECTOR, <replaceable class="parameter">vector2</replaceable> TSVECTOR) returns TSVECTOR 8140 </synopsis> 8141 </term> 8142 8143 <listitem> 8144 <indexterm>

