| 1 |
.. -*- rst -*- |
| 2 |
|
| 3 |
.. groonga-command |
| 4 |
.. database: normalisers |
| 5 |
|
| 6 |
Normalizers |
| 7 |
=========== |
| 8 |
|
| 9 |
Summary |
| 10 |
------- |
| 11 |
|
| 12 |
Groonga has normalizer module that normalizes text. It is used when |
| 13 |
tokenizing text and storing table key. For example, ``A`` and ``a`` |
| 14 |
are processed as the same character after normalization. |
| 15 |
|
| 16 |
Normalizer module can be added as a plugin. You can customize text |
| 17 |
normalization by registering your normalizer plugins to Groonga. |
| 18 |
|
| 19 |
A normalizer module is attached to a table. A table can have zero or |
| 20 |
one normalizer module. You can attach a normalizer module to a table |
| 21 |
by :ref:`table-create-normalizer` option in |
| 22 |
:doc:`/reference/commands/table_create`. |
| 23 |
|
| 24 |
Here is an example ``table_create`` that uses ``NormalizerAuto`` |
| 25 |
normalizer module: |
| 26 |
|
| 27 |
.. groonga-command |
| 28 |
.. include:: ../example/reference/normalizers/example-table-create.log |
| 29 |
.. table_create Dictionary TABLE_HASH_KEY ShortText --normalizer NormalizerAuto |
| 30 |
|
| 31 |
.. note:: |
| 32 |
|
| 33 |
Groonga 2.0.9 or earlier doesn't have ``--normalizer`` option in |
| 34 |
``table_create``. ``KEY_NORMALIZE`` flag was used instead. |
| 35 |
|
| 36 |
You can open an old database by Groonga 2.1.0 or later. An old |
| 37 |
database means that the database is created by Groonga 2.0.9 or |
| 38 |
earlier. But you cannot open the opened old database by Groonga |
| 39 |
2.0.9 or earlier. Once you open the old database by Groonga 2.1.0 |
| 40 |
or later, ``KEY_NORMALIZE`` flag information in the old database is |
| 41 |
converted to normalizer information. So Groonga 2.0.9 or earlier |
| 42 |
cannot find ``KEY_NORMALIZE`` flag information in the opened old |
| 43 |
database. |
| 44 |
|
| 45 |
Keys of a table that has a normalizer module are normalized: |
| 46 |
|
| 47 |
.. groonga-command |
| 48 |
.. include:: ../example/reference/normalizers/example-load.log |
| 49 |
.. load --table Dictionary |
| 50 |
.. [ |
| 51 |
.. {"_key": "Apple"}, |
| 52 |
.. {"_key": "black"}, |
| 53 |
.. {"_key": "COLOR"} |
| 54 |
.. ] |
| 55 |
.. select Dictionary |
| 56 |
|
| 57 |
``NormalizerAuto`` normalizer normalizes a text as a downcased text. |
| 58 |
For example, ``"Apple"`` is normalized to ``"apple"``, ``"black"`` is |
| 59 |
normalized to ``"black"`` and ``"COLOR"`` is normalized to |
| 60 |
``"color"``. |
| 61 |
|
| 62 |
If a table is a lexicon for fulltext search, tokenized tokens are |
| 63 |
normalized. Because tokens are stored as table keys. Table keys are |
| 64 |
normalized as described above. |
| 65 |
|
| 66 |
Built-in normalizers |
| 67 |
-------------------- |
| 68 |
|
| 69 |
Here is a list of built-in normalizers: |
| 70 |
|
| 71 |
.. toctree:: |
| 72 |
:maxdepth: 1 |
| 73 |
:glob: |
| 74 |
|
| 75 |
normalizers/* |
| 76 |
|
| 77 |
Additional normalizers |
| 78 |
---------------------- |
| 79 |
|
| 80 |
There are additional normalizers: |
| 81 |
|
| 82 |
* `groonga-normalizer-mysql <https://github.com/groonga/groonga-normalizer-mysql>`_ |
| 83 |
|
| 84 |
See also |
| 85 |
-------- |
| 86 |
|
| 87 |
* :doc:`/reference/commands/table_create` |