¾�ΥС�������ʸ�� �� 17 | 16 | 15 | 14 | 13 | 12 | 11 | 10 | 9.6 | 9.5 | 9.4 | 9.3 | 9.2 | 9.1 | 9.0 | 8.4 | 8.3 | 8.2 | 8.1 | 8.0 | 7.4 | 7.3 | 7.2

12.8. �ƥ����ȸ����Υƥ��ȤȥǥХå�

��������ƥ����ȸ�������ε�ư��ʣ���ˤʤ꤬���ǡ���̤Ȥ��ƺ���򾷤����Ȥˤʤ�ޤ������ξϤǤϡ��ƥ����ȸ������֥������ȤΥƥ��Ȥκݤ����Ω�Ĵؿ����������ޤ������꤬�������ɤ������ѡ����ȼ�����̡��˥ƥ��Ȥ��뤳�Ȥʤɤ���ǽ�Ǥ���

12.8.1. ����Υƥ���

ts_debug�ؿ��ˤ�ꡢ�ƥ����ȸ���������ưפʥƥ��Ȥ��Ǥ��ޤ���

ts_debug([ config regconfig, ] document text,
         OUT alias text,
         OUT description text,
         OUT token text,
         OUT dictionaries regdictionary[],
         OUT dictionary regdictionary,
         OUT lexemes text[])
         returns setof record

ts_debug�ϡ��ѡ����������������ꤵ�줿���񤬽�������document�Τ��٤ƤΥȡ�����ξ����ɽ�����ޤ������κݡ�config�ǻ��ꤷ�����꤬�Ȥ��ޤ�����������ά������default_text_search_config���Ȥ��ޤ���

ts_debug�ϡ��ѡ�����ǧ�������ƥ�������Υȡ������1�� �ˤĤ�����֤��ޤ����ֵѤ������ϰʲ��Ǥ���

��ñ����򼨤��ޤ���

SELECT * FROM ts_debug('english','a fat  cat sat on a mat - it ate a fat rats');
   alias   |   description   | token |  dictionaries  |  dictionary  | lexemes 
-----------+-----------------+-------+----------------+--------------+---------
 asciiword | Word, all ASCII | a     | {english_stem} | english_stem | {}
 blank     | Space symbols   |       | {}             |              | 
 asciiword | Word, all ASCII | fat   | {english_stem} | english_stem | {fat}
 blank     | Space symbols   |       | {}             |              | 
 asciiword | Word, all ASCII | cat   | {english_stem} | english_stem | {cat}
 blank     | Space symbols   |       | {}             |              | 
 asciiword | Word, all ASCII | sat   | {english_stem} | english_stem | {sat}
 blank     | Space symbols   |       | {}             |              | 
 asciiword | Word, all ASCII | on    | {english_stem} | english_stem | {}
 blank     | Space symbols   |       | {}             |              | 
 asciiword | Word, all ASCII | a     | {english_stem} | english_stem | {}
 blank     | Space symbols   |       | {}             |              | 
 asciiword | Word, all ASCII | mat   | {english_stem} | english_stem | {mat}
 blank     | Space symbols   |       | {}             |              | 
 blank     | Space symbols   | -     | {}             |              | 
 asciiword | Word, all ASCII | it    | {english_stem} | english_stem | {}
 blank     | Space symbols   |       | {}             |              | 
 asciiword | Word, all ASCII | ate   | {english_stem} | english_stem | {ate}
 blank     | Space symbols   |       | {}             |              | 
 asciiword | Word, all ASCII | a     | {english_stem} | english_stem | {}
 blank     | Space symbols   |       | {}             |              | 
 asciiword | Word, all ASCII | fat   | {english_stem} | english_stem | {fat}
 blank     | Space symbols   |       | {}             |              | 
 asciiword | Word, all ASCII | rats  | {english_stem} | english_stem | {rat}

�⤦�������٤ʥǥ�򤪸������뤿��ˡ��ޤ��Ѹ��Ѥ�public.english����ȡ�Ispell�������ޤ���

CREATE TEXT SEARCH CONFIGURATION public.english ( COPY = pg_catalog.english );

CREATE TEXT SEARCH DICTIONARY english_ispell (
    TEMPLATE = ispell,
    DictFile = english,
    AffFile = english,
    StopWords = english
);

ALTER TEXT SEARCH CONFIGURATION public.english
   ALTER MAPPING FOR asciiword WITH english_ispell, english_stem;
SELECT * FROM ts_debug('public.english','The Brightest supernovaes');
   alias   |   description   |    token    |         dictionaries          |   dictionary   |   lexemes   
-----------+-----------------+-------------+-------------------------------+----------------+-------------
 asciiword | Word, all ASCII | The         | {english_ispell,english_stem} | english_ispell | {}
 blank     | Space symbols   |             | {}                            |                | 
 asciiword | Word, all ASCII | Brightest   | {english_ispell,english_stem} | english_ispell | {bright}
 blank     | Space symbols   |             | {}                            |                | 
 asciiword | Word, all ASCII | supernovaes | {english_ispell,english_stem} | english_stem   | {supernova}

������Ǥϡ�ñ��Brightest�ϡ�ASCII word (�����ꥢ����asciiword)�Ȥ���ǧ������Ƥ��ޤ������Υȡ����󷿤Τ���μ���ꥹ�Ȥ�english_ispell ��english_stem�Ǥ�������ñ���english_ispell��ǧ�����졢̾��bright�ؤȽ��व��Ƥ��ޤ���ñ��supernovaes��english_ispell����ˤ�ǧ�����줺�����μ�����Ϥ��졢����ǧ������ޤ���(�ºݤˤϡ�english_stem��Snowball����ǡ����Ǥ�ǧ�����ޤ�������ǡ����μ���ϼ���ꥹ�ȤκǸ���֤���Ƥ���櫓�Ǥ�)��

ñ��The�ϡ�english_ispell����ˤ�äƥ��ȥåץ��(項12.6.1)�Ȥ���ǧ������Ƥ��ꡢ����ǥå����դ�����ޤ��󡣶����ΤƤ��ޤ�����������Ǥ϶���˴ؤ��뼭���󶡤���Ƥ��ʤ�����Ǥ���

����Ū�˸����������ꤹ�뤳�Ȥˤ�ꡢ���Ϥ����򸺤餹���Ȥ��Ǥ��ޤ���

SELECT alias, token, dictionary, lexemes
FROM ts_debug('public.english','The Brightest supernovaes');
   alias   |    token    |   dictionary   |   lexemes   
-----------+-------------+----------------+-------------
 asciiword | The         | english_ispell | {}
 blank     |             |                | 
 asciiword | Brightest   | english_ispell | {bright}
 blank     |             |                | 
 asciiword | supernovaes | english_stem   | {supernova}

12.8.2. �ѡ����Υƥ���

���ˤ������ؿ��ˤ�ꡢ�ƥ����ȸ����ѡ�����ľ�ܥƥ��Ȥ��뤳�Ȥ��Ǥ��ޤ���

ts_parse(parser_name text, document text,
         OUT tokid integer, OUT token text) returns setof record
ts_parse(parser_oid oid, document text,
         OUT tokid integer, OUT token text) returns setof record

ts_parse��Ϳ����줿document��ѡ��������ѡ��������������ȡ������1�Ԥ�1�Ĥ�İ�Ϣ�Υ쥳���ɤ��֤��ޤ������줾��Υ쥳���ɤˤϡ�������Ƥ�줿�ȡ����󷿤򼨤�tokid�ȡ��ƥ����ȤΥȡ�����Ǥ���token���ޤޤ�ޤ��� ��򼨤��ޤ���

SELECT * FROM ts_parse('default', '123 - a number');
 tokid | token
-------+--------
    22 | 123
    12 |
    12 | -
     1 | a
    12 |
     1 | number

ts_token_type(parser_name text, OUT tokid integer,
              OUT alias text, OUT description text) returns setof record
ts_token_type(parser_oid oid, OUT tokid integer,
              OUT alias text, OUT description text) returns setof record

ts_token_type�ϡ����ꤷ���ѡ�����ǧ���Ǥ���ȡ����󷿤򵭽Ҥ����ơ��֥���֤��ޤ����ơ��Υȡ����󷿤��Ф����ѡ������ȡ����󷿤��٥��դ�����Τ˻��Ѥ�������tokid�����ꥳ�ޥ����Υȡ������̾���Ǥ���alias����ñ�������Ǥ���description���ޤޤ�ޤ��� ��򼨤��ޤ���

SELECT * FROM ts_token_type('default');
 tokid |      alias      |               description                
-------+-----------------+------------------------------------------
     1 | asciiword       | Word, all ASCII
     2 | word            | Word, all letters
     3 | numword         | Word, letters and digits
     4 | email           | Email address
     5 | url             | URL
     6 | host            | Host
     7 | sfloat          | Scientific notation
     8 | version         | Version number
     9 | hword_numpart   | Hyphenated word part, letters and digits
    10 | hword_part      | Hyphenated word part, all letters
    11 | hword_asciipart | Hyphenated word part, all ASCII
    12 | blank           | Space symbols
    13 | tag             | XML tag
    14 | protocol        | Protocol head
    15 | numhword        | Hyphenated word, letters and digits
    16 | asciihword      | Hyphenated word, all ASCII
    17 | hword           | Hyphenated word, all letters
    18 | url_path        | URL path
    19 | file            | File or path name
    20 | float           | Decimal notation
    21 | int             | Signed integer
    22 | uint            | Unsigned integer
    23 | entity          | XML entity

12.8.3. ����Υƥ���

ts_lexize�ؿ��ϼ���Υƥ��Ȥ�ٱ礷�ޤ���

ts_lexize(dict regdictionary, token text) returns text[]

ts_lexize�ϡ�����token�������ǧ�������и����Ǥ�������֤��ޤ��������ǧ�����졢���줬���ȥåץ�ɤǤ�����ˤ϶���������֤��ޤ���ǧ������ʤ����NULL���֤��ޤ���

��:

SELECT ts_lexize('english_stem', 'stars');
 ts_lexize
-----------
 {star}

SELECT ts_lexize('english_stem', 'a');
 ts_lexize
-----------
 {}

注意: ts_lexize�ؿ��ˤϡ��ƥ����ȤǤϤʤ�ñ����ȡ�������Ϳ���ޤ��������ְ㤨��ȼ��Τ褦�ˤʤ�ޤ���

SELECT ts_lexize('thesaurus_astro','supernovae stars') is null;
 ?column?
----------
 t

��켭��thesaurus_astro�ϸ��supernovae stars��ǧ�����ޤ�����ts_lexize�Ϥ��ޤ��󡣤ʤ��ʤ顢���Ϥ�ƥ����ȤǤϤʤ���ñ��Υȡ�����Ȥ��ư�������Ǥ�����켭���ƥ��Ȥ���ˤϡ�plainto_tsquery�ޤ���to_tsvector��ȤäƤ�����������򼨤��ޤ���

SELECT plainto_tsquery('supernovae stars');
 plainto_tsquery
-----------------
 'sn'