| 1 |
.. -*- rst -*- |
| 2 |
|
| 3 |
.. groonga-command |
| 4 |
.. database: reindex |
| 5 |
|
| 6 |
``reindex`` |
| 7 |
=========== |
| 8 |
|
| 9 |
Summary |
| 10 |
------- |
| 11 |
|
| 12 |
.. versionadded:: 5.1.0 |
| 13 |
|
| 14 |
``reindex`` command recreates one or more index columns. |
| 15 |
|
| 16 |
If you specify a database as target object, all index columns are |
| 17 |
recreated. |
| 18 |
|
| 19 |
If you specify a table as target object, all index columns in the |
| 20 |
table are recreated. |
| 21 |
|
| 22 |
If you specify a data column as target object, all index columns for |
| 23 |
the data column are recreated. |
| 24 |
|
| 25 |
If you specify an index column as target object, the index column is |
| 26 |
recreated. |
| 27 |
|
| 28 |
This command is useful when your index column is broken. The target |
| 29 |
object is one of database, table and column. |
| 30 |
|
| 31 |
.. note:: |
| 32 |
|
| 33 |
You can't use target index columns while ``reindex`` command is |
| 34 |
running. If you use the same database from multiple processes, all |
| 35 |
processes except running ``reindex`` should reopen the |
| 36 |
database. You can use :doc:`database_unmap` for reopening database. |
| 37 |
|
| 38 |
Syntax |
| 39 |
------ |
| 40 |
|
| 41 |
This command takes only one optional parameter:: |
| 42 |
|
| 43 |
reindex [target_name=null] |
| 44 |
|
| 45 |
If ``target_name`` parameters is omitted, database is used for the |
| 46 |
target object. It means that all index columns in the database are |
| 47 |
recreated. |
| 48 |
|
| 49 |
Usage |
| 50 |
----- |
| 51 |
|
| 52 |
Here is an example to recreate all index columns in the database: |
| 53 |
|
| 54 |
.. groonga-command |
| 55 |
.. include:: ../../example/reference/commands/reindex/database.log |
| 56 |
.. reindex |
| 57 |
|
| 58 |
Here is an example to recreate all index columns |
| 59 |
(``Lexicon.entry_key`` and ``Lexicon.entry_body``) in ``Lexicon`` |
| 60 |
table: |
| 61 |
|
| 62 |
.. groonga-command |
| 63 |
.. include:: ../../example/reference/commands/reindex/table.log |
| 64 |
.. table_create Entry TABLE_HASH_KEY ShortText |
| 65 |
.. column_create Entry body COLUMN_SCALAR Text |
| 66 |
.. |
| 67 |
.. table_create Lexicon TABLE_PAT_KEY ShortText \ |
| 68 |
.. --default_tokenizer TokenBigram \ |
| 69 |
.. --normalizer NormalizerAuto |
| 70 |
.. column_create Lexicon entry_key COLUMN_INDEX|WITH_POSITION \ |
| 71 |
.. Entry _key |
| 72 |
.. column_create Lexicon entry_body COLUMN_INDEX|WITH_POSITION \ |
| 73 |
.. Entry body |
| 74 |
.. |
| 75 |
.. reindex Lexicon |
| 76 |
|
| 77 |
Here is an example to recreate all index columns |
| 78 |
(``BigramLexicon.site_title`` and ``RegexpLexicon.site_title``) of |
| 79 |
``Site.title`` data column: |
| 80 |
|
| 81 |
.. groonga-command |
| 82 |
.. include:: ../../example/reference/commands/reindex/data_column.log |
| 83 |
.. table_create Site TABLE_HASH_KEY ShortText |
| 84 |
.. column_create Site title COLUMN_SCALAR ShortText |
| 85 |
.. |
| 86 |
.. table_create BigramLexicon TABLE_PAT_KEY ShortText \ |
| 87 |
.. --default_tokenizer TokenBigram \ |
| 88 |
.. --normalizer NormalizerAuto |
| 89 |
.. column_create BigramLexicon site_title COLUMN_INDEX|WITH_POSITION \ |
| 90 |
.. Site title |
| 91 |
.. |
| 92 |
.. table_create RegexpLexicon TABLE_PAT_KEY ShortText \ |
| 93 |
.. --default_tokenizer TokenRegexp \ |
| 94 |
.. --normalizer NormalizerAuto |
| 95 |
.. column_create RegexpLexicon site_title COLUMN_INDEX|WITH_POSITION \ |
| 96 |
.. Site title |
| 97 |
.. |
| 98 |
.. reindex Site.title |
| 99 |
|
| 100 |
Here is an example to recreate an index column (``Timestamp.index``): |
| 101 |
|
| 102 |
.. groonga-command |
| 103 |
.. include:: ../../example/reference/commands/reindex/index_column.log |
| 104 |
.. table_create Logs TABLE_NO_KEY |
| 105 |
.. column_create Logs timestamp COLUMN_SCALAR Time |
| 106 |
.. |
| 107 |
.. table_create Timestamp TABLE_PAT_KEY Time |
| 108 |
.. column_create Timestamp logs_timestamp COLUMN_INDEX Logs timestamp |
| 109 |
.. |
| 110 |
.. reindex Timestamp.logs_timestamp |
| 111 |
|
| 112 |
Parameters |
| 113 |
---------- |
| 114 |
|
| 115 |
This section describes all parameters. |
| 116 |
|
| 117 |
``target_name`` |
| 118 |
""""""""""""""" |
| 119 |
|
| 120 |
Specifies the name of table or column. |
| 121 |
|
| 122 |
If you don't specify it, database is used for the target object. |
| 123 |
|
| 124 |
The default is none. It means that the target object is database. |
| 125 |
|
| 126 |
Return value |
| 127 |
------------ |
| 128 |
|
| 129 |
``reindex`` command returns whether recreation is succeeded or not:: |
| 130 |
|
| 131 |
[HEADER, SUCCEEDED_OR_NOT] |
| 132 |
|
| 133 |
``HEADER`` |
| 134 |
|
| 135 |
See :doc:`/reference/command/output_format` about ``HEADER``. |
| 136 |
|
| 137 |
``SUCCEEDED_OR_NOT`` |
| 138 |
|
| 139 |
If command succeeded, it returns true, otherwise it returns false on |
| 140 |
error. |