バージョンごとのドキュメント一覧

F.13. dict_int — 整数のための全文検索用の辞書の例 #

<title>dict_int &mdash; example full-text search dictionary for integers</title>

<filename>dict_int</filename> is an example of an add-on dictionary template for full-text search. The motivation for this example dictionary is to control the indexing of integers (signed and unsigned), allowing such numbers to be indexed while preventing excessive growth in the number of unique words, which greatly affects the performance of searching. dict_intは、全文検索用の辞書テンプレートの追加例です。 この辞書例の目的は、検索性能に大きく影響する一意な単語数の急激な増大を防ぎながら、こうした数のインデックス付けを行うことができるように、整数(符号付きおよび符号無)のインデックス付けを制御することです。

This module is considered <quote>trusted</quote>, that is, it can be installed by non-superusers who have <literal>CREATE</literal> privilege on the current database. このモジュールはtrustedと見なされます。つまり、現在のデータベースに対してCREATE権限を持つ非スーパーユーザがインストールできます。

F.13.1. 設定 #

<title>Configuration</title>

The dictionary accepts three options: この辞書は3つのオプションを受け付けます。

  • The <literal>maxlen</literal> parameter specifies the maximum number of digits allowed in an integer word. The default value is 6. maxlenパラメータは整数型の単語で許される最大桁数を指定します。 デフォルト値は6です。

  • The <literal>rejectlong</literal> parameter specifies whether an overlength integer should be truncated or ignored. If <literal>rejectlong</literal> is <literal>false</literal> (the default), the dictionary returns the first <literal>maxlen</literal> digits of the integer. If <literal>rejectlong</literal> is <literal>true</literal>, the dictionary treats an overlength integer as a stop word, so that it will not be indexed. Note that this also means that such an integer cannot be searched for. rejectlongパラメータは、桁数を超える整数を切り詰めるか無視するかを指定します。 rejectlongfalse(デフォルト)ならば、辞書は整数の先頭のmaxlen桁を返します。 rejectlongtrueならば、辞書は桁数を超えた整数をストップワードとして扱います。 このためインデックス付けされません。 これはまた、こうした整数を検索することができないことを意味します。

  • The <literal>absval</literal> parameter specifies whether leading <quote><literal>+</literal></quote> or <quote><literal>-</literal></quote> signs should be removed from integer words. The default is <literal>false</literal>. When <literal>true</literal>, the sign is removed before <literal>maxlen</literal> is applied. absvalパラメータは、先頭の+または-符号を整数型の単語から削除するかどうかを指定します。 デフォルトはfalseです。 trueの場合、maxlenが適用される前に符号は削除されます。

F.13.2. 使用方法 #

<title>Usage</title>

Installing the <literal>dict_int</literal> extension creates a text search template <literal>intdict_template</literal> and a dictionary <literal>intdict</literal> based on it, with the default parameters. You can alter the parameters, for example dict_int拡張機能をインストールすると、intdict_templateテキスト検索テンプレートとこれに基づき、そのデフォルト値でintdict辞書が作成されます。 以下のようにパラメータを変更することができます。

mydb# ALTER TEXT SEARCH DICTIONARY intdict (MAXLEN = 4, REJECTLONG = true);
ALTER TEXT SEARCH DICTIONARY

or create new dictionaries based on the template. または、このテンプレートを基に新しい辞書を作成してください。

To test the dictionary, you can try 辞書を試験するためには以下を試してください。

mydb# select ts_lexize('intdict', '12345678');
 ts_lexize
-----------
 {123456}

but real-world usage will involve including it in a text search configuration as described in <xref linkend="textsearch"/>. That might look like this: しかし、現実世界で使用する場合は、第12章で説明されるテキスト検索設定内にこれを含むようになるでしょう。 以下のようになります。

ALTER TEXT SEARCH CONFIGURATION english
    ALTER MAPPING FOR int, uint WITH intdict;