set up the mappings for words in configuration
<literal>pg</literal>:
<programlisting>
ALTER TEXT SEARCH CONFIGURATION pg
ALTER MAPPING FOR asciiword, asciihword, hword_asciipart,
word, hword, hword_part
WITH pg_dict, english_ispell, english_stem;
</programlisting>
We choose not to index or search some token types that the built-in
configuration does handle:
<programlisting>
ALTER TEXT SEARCH CONFIGURATION pg
DROP MAPPING FOR email, url, url_path, sfloat, float;
</programlisting>
</para>
<para>
Now we can test our configuration:
<programlisting>
SELECT * FROM ts_debug('public.pg', '
PostgreSQL, the highly scalable, SQL compliant, open source object-relational
database management system, is now undergoing beta testing of the next
version of our software.
');
</programlisting>
</para>
<para>
The next step is to set the session to use the new configuration, which was
created in the <literal>public</literal> schema:
<screen>
=> \dF
List of text search configurations
Schema | Name | Description
---------+------+-------------
public | pg |
SET default_text_search_config = 'public.pg';
SET
SHOW default_text_search_config;
default_text_search_config
----------------------------
public.pg
</screen>
</para>
</sect1>
<sect1 id="textsearch-debugging">
<title>Testing and Debugging Text Search</title>
<para>
The behavior of a custom text search configuration can easily become
confusing. The functions described
in this section are useful for testing text search objects. You can
test a complete configuration, or test parsers and dictionaries separately.
</para>
<sect2 id="textsearch-configuration-testing">
<title>Configuration Testing</title>
<para>
The function <function>ts_debug</function> allows easy testing of a
text search configuration.
</para>
<indexterm>
<primary>ts_debug</primary>
</indexterm>
<synopsis>
ts_debug(<optional> <replaceable class="parameter">config</replaceable> <type>regconfig</type>, </optional> <replaceable class="parameter">document</replaceable> <type>text</type>,
OUT <replaceable class="parameter">alias</replaceable> <type>text</type>,
OUT <replaceable class="parameter">description</replaceable> <type>text</type>,
OUT <replaceable class="parameter">token</replaceable> <type>text</type>,
OUT <replaceable class="parameter">dictionaries</replaceable> <type>regdictionary[]</type>,
OUT <replaceable class="parameter">dictionary</replaceable> <type>regdictionary</type>,
OUT <replaceable class="parameter">lexemes</replaceable> <type>text[]</type>)
returns setof record
</synopsis>
<para>
<function>ts_debug</function> displays information about every token of
<replaceable class="parameter">document</replaceable> as produced by the
parser and processed by the configured dictionaries. It uses the
configuration specified by <replaceable
class="parameter">config</replaceable>,
or <varname>default_text_search_config</varname> if that argument is
omitted.
</para>
<para>
<function>ts_debug</function> returns one row for each token identified in the text
by the parser. The columns returned are
<itemizedlist spacing="compact" mark="bullet">
<listitem>
<para>
<replaceable>alias</replaceable> <type>text</type> — short name of the token type
</para>
</listitem>
<listitem>
<para>
<replaceable>description</replaceable> <type>text</type> — description of the
token type
</para>
</listitem>
<listitem>
<para>
<replaceable>token</replaceable> <type>text</type> — text of the token
</para>
</listitem>
<listitem>
<para>
<replaceable>dictionaries</replaceable> <type>regdictionary[]</type> — the
dictionaries selected by the configuration for this token type