| 1 |
.. -*- rst -*- |
| 2 |
|
| 3 |
.. groonga-command |
| 4 |
.. database: schema |
| 5 |
|
| 6 |
``schema`` |
| 7 |
========== |
| 8 |
|
| 9 |
Summary |
| 10 |
------- |
| 11 |
|
| 12 |
.. versionadded:: 5.0.9 |
| 13 |
|
| 14 |
``schema`` command returns schema in the database. |
| 15 |
|
| 16 |
This command is useful when you want to inspect the database. For |
| 17 |
example, visualizing the database, creating GUI for the database and |
| 18 |
so on. |
| 19 |
|
| 20 |
Syntax |
| 21 |
------ |
| 22 |
|
| 23 |
This command takes no parameters:: |
| 24 |
|
| 25 |
schema |
| 26 |
|
| 27 |
Usage |
| 28 |
----- |
| 29 |
|
| 30 |
Here is an example schema to show example output: |
| 31 |
|
| 32 |
.. groonga-command |
| 33 |
.. include:: ../../example/reference/commands/schema/sample.log |
| 34 |
.. table_create Memos TABLE_HASH_KEY ShortText |
| 35 |
.. column_create Memos content COLUMN_SCALAR Text |
| 36 |
.. |
| 37 |
.. table_create Terms TABLE_PAT_KEY ShortText \ |
| 38 |
.. --default_tokenizer TokenBigram \ |
| 39 |
.. --normalizer NormalizerAuto |
| 40 |
.. column_create Terms memos_content_index \ |
| 41 |
.. COLUMN_INDEX|WITH_POSITION \ |
| 42 |
.. Memos content |
| 43 |
|
| 44 |
Here is an output of ``schema`` command against this example schema: |
| 45 |
|
| 46 |
.. groonga-command |
| 47 |
.. include:: ../../example/reference/commands/schema/output.log |
| 48 |
.. schema |
| 49 |
|
| 50 |
Parameters |
| 51 |
---------- |
| 52 |
|
| 53 |
This section describes all parameters. |
| 54 |
|
| 55 |
Required parameters |
| 56 |
^^^^^^^^^^^^^^^^^^^ |
| 57 |
|
| 58 |
There is no required parameter. |
| 59 |
|
| 60 |
Optional parameters |
| 61 |
^^^^^^^^^^^^^^^^^^^ |
| 62 |
|
| 63 |
There is no optional parameter. |
| 64 |
|
| 65 |
Return value |
| 66 |
------------ |
| 67 |
|
| 68 |
``schema`` command returns schema in the database:: |
| 69 |
|
| 70 |
[HEADER, SCHEMA] |
| 71 |
|
| 72 |
``HEADER`` |
| 73 |
^^^^^^^^^^ |
| 74 |
|
| 75 |
See :doc:`/reference/command/output_format` about ``HEADER``. |
| 76 |
|
| 77 |
``SCHEMA`` |
| 78 |
^^^^^^^^^^ |
| 79 |
|
| 80 |
``SCHEMA`` is an object that consists of the following information:: |
| 81 |
|
| 82 |
{ |
| 83 |
"plugins": PLUGINS, |
| 84 |
"types": TYPES, |
| 85 |
"tokenizers": TOKENIZERS, |
| 86 |
"normalizers": NORMALIZERS, |
| 87 |
"token_filters": TOKEN_FITLERS, |
| 88 |
"tables": TABLES |
| 89 |
} |
| 90 |
|
| 91 |
``PLUGINS`` |
| 92 |
^^^^^^^^^^^ |
| 93 |
|
| 94 |
``PLUGINS`` is an object. Its key is plugin name and its value is |
| 95 |
plugin detail:: |
| 96 |
|
| 97 |
{ |
| 98 |
"PLUGIN_NAME_1": PLUGIN_1, |
| 99 |
"PLUGIN_NAME_2": PLUGIN_2, |
| 100 |
... |
| 101 |
"PLUGIN_NAME_n": PLUGIN_n |
| 102 |
} |
| 103 |
|
| 104 |
``PLUGIN`` |
| 105 |
^^^^^^^^^^ |
| 106 |
|
| 107 |
``PLUGIN`` is an object that describes plugin detail:: |
| 108 |
|
| 109 |
{ |
| 110 |
"name": PLUGIN_NAME |
| 111 |
} |
| 112 |
|
| 113 |
Here are properties of ``PLUGIN``: |
| 114 |
|
| 115 |
.. list-table:: |
| 116 |
:header-rows: 1 |
| 117 |
|
| 118 |
* - Name |
| 119 |
- Description |
| 120 |
* - ``name`` |
| 121 |
- The plugin name. It's used in :doc:`plugin_register`. |
| 122 |
|
| 123 |
``TYPES`` |
| 124 |
^^^^^^^^^ |
| 125 |
|
| 126 |
``TYPES`` is an object. Its key is type name and its value is |
| 127 |
type detail:: |
| 128 |
|
| 129 |
{ |
| 130 |
"TYPE_NAME_1": TYPE_1, |
| 131 |
"TYPE_NAME_2": TYPE_2, |
| 132 |
... |
| 133 |
"TYPE_NAME_n": TYPE_n |
| 134 |
} |
| 135 |
|
| 136 |
``TYPE`` |
| 137 |
^^^^^^^^ |
| 138 |
|
| 139 |
``TYPE`` is an object that describes type detail:: |
| 140 |
|
| 141 |
{ |
| 142 |
"name": TYPE_NAME, |
| 143 |
"size": SIZE_OF_ONE_VALUE_IN_BYTE, |
| 144 |
"can_be_key_type": BOOLEAN, |
| 145 |
"can_be_value_type": BOOLEAN |
| 146 |
} |
| 147 |
|
| 148 |
Here are properties of ``TYPE``: |
| 149 |
|
| 150 |
.. list-table:: |
| 151 |
:header-rows: 1 |
| 152 |
|
| 153 |
* - Name |
| 154 |
- Description |
| 155 |
* - ``name`` |
| 156 |
- The type name. |
| 157 |
* - ``size`` |
| 158 |
- The number of bytes of one value. |
| 159 |
* - ``can_be_key_type`` |
| 160 |
- ``true`` when the type can be used for table key, ``false`` |
| 161 |
otherwise. |
| 162 |
* - ``can_be_value_type`` |
| 163 |
- ``true`` when the type can be used for table value, ``false`` |
| 164 |
otherwise. |
| 165 |
|
| 166 |
``TOKENIZERS`` |
| 167 |
^^^^^^^^^^^^^^ |
| 168 |
|
| 169 |
``TOKENIZERS`` is an object. Its key is tokenizer name and its value |
| 170 |
is tokenizer detail:: |
| 171 |
|
| 172 |
{ |
| 173 |
"TOKENIZER_NAME_1": TOKENIZER_1, |
| 174 |
"TOKENIZER_NAME_2": TOKENIZER_2, |
| 175 |
... |
| 176 |
"TOKENIZER_NAME_n": TOKENIZER_n |
| 177 |
} |
| 178 |
|
| 179 |
``TOKENIZER`` |
| 180 |
^^^^^^^^^^^^^ |
| 181 |
|
| 182 |
``TOKENIZER`` is an object that describes tokenizer detail:: |
| 183 |
|
| 184 |
{ |
| 185 |
"name": TOKENIZER_NAME |
| 186 |
} |
| 187 |
|
| 188 |
Here are properties of ``TOKENIZER``: |
| 189 |
|
| 190 |
.. list-table:: |
| 191 |
:header-rows: 1 |
| 192 |
|
| 193 |
* - Name |
| 194 |
- Description |
| 195 |
* - ``name`` |
| 196 |
- The tokenizer name. It's used for |
| 197 |
:ref:`table-create-default-tokenizer`. |
| 198 |
|
| 199 |
``NORMALIZERS`` |
| 200 |
^^^^^^^^^^^^^^^ |
| 201 |
|
| 202 |
``NORMALIZERS`` is an object. Its key is normalizer name and its value |
| 203 |
is normalizer detail:: |
| 204 |
|
| 205 |
{ |
| 206 |
"NORMALIZER_NAME_1": NORMALIZER_1, |
| 207 |
"NORMALIZER_NAME_2": NORMALIZER_2, |
| 208 |
... |
| 209 |
"NORMALIZER_NAME_n": NORMALIZER_n |
| 210 |
} |
| 211 |
|
| 212 |
``NORMALIZER`` |
| 213 |
^^^^^^^^^^^^^^ |
| 214 |
|
| 215 |
``NORMALIZER`` is an object that describes normalizer detail:: |
| 216 |
|
| 217 |
{ |
| 218 |
"name": NORMALIZER_NAME |
| 219 |
} |
| 220 |
|
| 221 |
Here are properties of ``NORMALIZER``: |
| 222 |
|
| 223 |
.. list-table:: |
| 224 |
:header-rows: 1 |
| 225 |
|
| 226 |
* - Name |
| 227 |
- Description |
| 228 |
* - ``name`` |
| 229 |
- The normalizer name. It's used for |
| 230 |
:ref:`table-create-normalizer`. |
| 231 |
|
| 232 |
``TOKEN_FILTERS`` |
| 233 |
^^^^^^^^^^^^^^^^^ |
| 234 |
|
| 235 |
``TOKEN_FILTERS`` is an object. Its key is token filter name and its value |
| 236 |
is token filter detail:: |
| 237 |
|
| 238 |
{ |
| 239 |
"TOKEN_FILTER_NAME_1": TOKEN_FILTER_1, |
| 240 |
"TOKEN_FILTER_NAME_2": TOKEN_FILTER_2, |
| 241 |
... |
| 242 |
"TOKEN_FILTER_NAME_n": TOKEN_FILTER_n |
| 243 |
} |
| 244 |
|
| 245 |
``TOKEN_FILTER`` |
| 246 |
^^^^^^^^^^^^^^^^ |
| 247 |
|
| 248 |
``TOKEN_FILTER`` is an object that describes token filter detail:: |
| 249 |
|
| 250 |
{ |
| 251 |
"name": TOKEN_FILTER_NAME |
| 252 |
} |
| 253 |
|
| 254 |
Here are properties of ``TOKEN_FILTER``: |
| 255 |
|
| 256 |
.. list-table:: |
| 257 |
:header-rows: 1 |
| 258 |
|
| 259 |
* - Name |
| 260 |
- Description |
| 261 |
* - ``name`` |
| 262 |
- The token filter name. It's used for |
| 263 |
:ref:`table-create-token-filters`. |
| 264 |
|
| 265 |
``TABLES`` |
| 266 |
^^^^^^^^^^ |
| 267 |
|
| 268 |
``TABLES`` is an object. Its key is table name and its value |
| 269 |
is table detail:: |
| 270 |
|
| 271 |
{ |
| 272 |
"TABLE_NAME_1": TABLE_1, |
| 273 |
"TABLE_NAME_2": TABLE_2, |
| 274 |
... |
| 275 |
"TABLE_NAME_n": TABLE_n |
| 276 |
} |
| 277 |
|
| 278 |
``TABLE`` |
| 279 |
^^^^^^^^^ |
| 280 |
|
| 281 |
``TABLE`` is an object that describes table detail:: |
| 282 |
|
| 283 |
{ |
| 284 |
"name": TABLE_NAME |
| 285 |
"type": TYPE, |
| 286 |
"key_type": KEY_TYPE, |
| 287 |
"value_type": VALUE_TYPE, |
| 288 |
"tokenizer": TOKENIZER, |
| 289 |
"normalizer": NORMALIZER, |
| 290 |
"token_filters": [ |
| 291 |
TOKEN_FILTER_1, |
| 292 |
TOKEN_FILTER_2, |
| 293 |
..., |
| 294 |
TOKEN_FILTER_n, |
| 295 |
], |
| 296 |
"indexes": [ |
| 297 |
INDEX_1, |
| 298 |
INDEX_2, |
| 299 |
..., |
| 300 |
INDEX_n |
| 301 |
], |
| 302 |
"command": COMMAND, |
| 303 |
"columns": { |
| 304 |
"COLUMN_NAME_1": COLUMN_1, |
| 305 |
"COLUMN_NAME_2": COLUMN_2, |
| 306 |
..., |
| 307 |
"COLUMN_NAME_3": COLUMN_3, |
| 308 |
} |
| 309 |
} |
| 310 |
|
| 311 |
Here are properties of ``TABLE``: |
| 312 |
|
| 313 |
.. list-table:: |
| 314 |
:header-rows: 1 |
| 315 |
|
| 316 |
* - Name |
| 317 |
- Description |
| 318 |
* - ``name`` |
| 319 |
- The table name. |
| 320 |
* - ``type`` |
| 321 |
- The table type. |
| 322 |
|
| 323 |
This is one of the followings: |
| 324 |
|
| 325 |
* ``array``: :ref:`table-no-key` |
| 326 |
* ``hash``: :ref:`table-hash-key` |
| 327 |
* ``patricia trie``: :ref:`table-pat-key` |
| 328 |
* ``double array trie``: :ref:`table-dat-key` |
| 329 |
* - ``key_type`` |
| 330 |
- The type of the table's key. |
| 331 |
|
| 332 |
If the table type is ``array``, this is ``null``. |
| 333 |
|
| 334 |
If the table type isn't ``array``, this is an object |
| 335 |
that has the following properties: |
| 336 |
|
| 337 |
* ``name``: The type name. |
| 338 |
* ``type``: ``reference`` if the type is an table, ``type`` |
| 339 |
otherwise. |
| 340 |
* - ``value_type`` |
| 341 |
- The type of the table's value. |
| 342 |
|
| 343 |
If the table doesn't use value, this is ``null``. |
| 344 |
|
| 345 |
If the table uses value, this is an object that has the |
| 346 |
following properties: |
| 347 |
|
| 348 |
* ``name``: The type name. |
| 349 |
* ``type``: ``reference`` if the type is an table, ``type`` |
| 350 |
otherwise. |
| 351 |
* - ``tokenizer`` |
| 352 |
- The tokenizer of the table. It's specified by |
| 353 |
:ref:`table-create-default-tokenizer`. |
| 354 |
|
| 355 |
If the table doesn't use tokenizer, this is ``null``. |
| 356 |
|
| 357 |
If the table uses tokenizer, this is an object that has the |
| 358 |
following properties: |
| 359 |
|
| 360 |
* ``name``: The tokenizer name. |
| 361 |
* - ``normalizer`` |
| 362 |
- The normalizer of the table. It's specified by |
| 363 |
:ref:`table-create-normalizer`. |
| 364 |
|
| 365 |
If the table doesn't use normalizer, this is ``null``. |
| 366 |
|
| 367 |
If the table uses normalizer, this is an object that has the |
| 368 |
following properties: |
| 369 |
|
| 370 |
* ``name``: The normalizer name. |
| 371 |
* - ``token_filters`` |
| 372 |
- The token filters of the table. It's specified by |
| 373 |
:ref:`table-create-token-filters`. |
| 374 |
|
| 375 |
This is an array of an object. The object has the following |
| 376 |
properties: |
| 377 |
|
| 378 |
* ``name``: The token filter name. |
| 379 |
* - ``indexes`` |
| 380 |
- The indexes of the table's key. |
| 381 |
|
| 382 |
This is an array of :ref:`schema-return-value-index`. |
| 383 |
* - ``command`` |
| 384 |
- The Groonga command information to create the table. |
| 385 |
|
| 386 |
This is :ref:`schema-return-value-command`. |
| 387 |
* - ``columns`` |
| 388 |
- The columns of the table. |
| 389 |
|
| 390 |
This is an object that its key is a column name and its value |
| 391 |
is :ref:`schema-return-value-column`. |
| 392 |
|
| 393 |
.. _schema-return-value-index: |
| 394 |
|
| 395 |
``INDEX`` |
| 396 |
^^^^^^^^^ |
| 397 |
|
| 398 |
``INDEX`` is an object that describes index detail:: |
| 399 |
|
| 400 |
{ |
| 401 |
"full_name": INDEX_COLUMN_NAME_WITH_TABLE_NAME, |
| 402 |
"table": TABLE_NAME, |
| 403 |
"name": INDEX_COLUMN_NAME, |
| 404 |
"section": SECTION |
| 405 |
} |
| 406 |
|
| 407 |
Here are properties of ``INDEX``: |
| 408 |
|
| 409 |
.. list-table:: |
| 410 |
:header-rows: 1 |
| 411 |
|
| 412 |
* - Name |
| 413 |
- Description |
| 414 |
* - ``full_name`` |
| 415 |
- The index column name with table name. |
| 416 |
|
| 417 |
For example, ``Terms.index``. |
| 418 |
* - ``table`` |
| 419 |
- The table name of the index column. |
| 420 |
|
| 421 |
For example, ``Terms``. |
| 422 |
* - ``name`` |
| 423 |
- The index column name. |
| 424 |
|
| 425 |
For example, ``index``. |
| 426 |
* - ``section`` |
| 427 |
- The section number in the index column for the table's key. |
| 428 |
|
| 429 |
If the index column isn't multiple column index, this is ``0``. |
| 430 |
|
| 431 |
.. _schema-return-value-command: |
| 432 |
|
| 433 |
``COMMAND`` |
| 434 |
^^^^^^^^^^^ |
| 435 |
|
| 436 |
``COMMAND`` is an object that describes how to create the table or |
| 437 |
column:: |
| 438 |
|
| 439 |
{ |
| 440 |
"name": COMMAND_NAME, |
| 441 |
"arguments": { |
| 442 |
"KEY_1": "VALUE_1", |
| 443 |
"KEY_2": "VALUE_2", |
| 444 |
..., |
| 445 |
"KEY_n": "VALUE_n" |
| 446 |
}, |
| 447 |
"command_line": COMMAND_LINE |
| 448 |
} |
| 449 |
|
| 450 |
Here are properties of ``COMMAND``: |
| 451 |
|
| 452 |
.. list-table:: |
| 453 |
:header-rows: 1 |
| 454 |
|
| 455 |
* - Name |
| 456 |
- Description |
| 457 |
* - ``name`` |
| 458 |
- The Groonga command name to create the table or column. |
| 459 |
* - ``arguments`` |
| 460 |
- The arguments of the Groonga command to create the |
| 461 |
table or column. |
| 462 |
|
| 463 |
This is an object that its key is argument name and its value |
| 464 |
is argument value. |
| 465 |
* - ``command_line`` |
| 466 |
- The Groonga command line to create the table or column. |
| 467 |
|
| 468 |
This is a string that can be evaluated by Groonga. |
| 469 |
|
| 470 |
.. _schema-return-value-column: |
| 471 |
|
| 472 |
``COLUMN`` |
| 473 |
^^^^^^^^^^ |
| 474 |
|
| 475 |
``COLUMN`` is an object that describes column detail:: |
| 476 |
|
| 477 |
{ |
| 478 |
"name": COLUMN_NAME, |
| 479 |
"table": TABLE_NAME, |
| 480 |
"full_name": COLUMN_NAME_WITH_TABLE, |
| 481 |
"type": TYPE, |
| 482 |
"value_type": VALUE_TYPE, |
| 483 |
"compress": COMPRESS, |
| 484 |
"section": SECTION, |
| 485 |
"weight": WEIGHT, |
| 486 |
"compress": COMPRESS, |
| 487 |
"section": BOOLEAN, |
| 488 |
"weight": BOOLEAN, |
| 489 |
"position": BOOLEAN, |
| 490 |
"sources": [ |
| 491 |
SOURCE_1, |
| 492 |
SOURCE_2, |
| 493 |
..., |
| 494 |
SOURCE_n |
| 495 |
], |
| 496 |
"generator": GENERATOR, |
| 497 |
"indexes": [ |
| 498 |
INDEX_1, |
| 499 |
INDEX_2, |
| 500 |
..., |
| 501 |
INDEX_n |
| 502 |
], |
| 503 |
"command": COMMAND |
| 504 |
} |
| 505 |
|
| 506 |
Here are properties of ``COLUMN``: |
| 507 |
|
| 508 |
.. list-table:: |
| 509 |
:header-rows: 1 |
| 510 |
|
| 511 |
* - Name |
| 512 |
- Description |
| 513 |
* - ``name`` |
| 514 |
- The column name. |
| 515 |
|
| 516 |
For example, ``age``. |
| 517 |
* - ``table`` |
| 518 |
- The table name of the column. |
| 519 |
|
| 520 |
For example, ``Users``. |
| 521 |
* - ``full_name`` |
| 522 |
- The column name with table name. |
| 523 |
|
| 524 |
For example, ``Users.age``. |
| 525 |
* - ``type`` |
| 526 |
- The column type. |
| 527 |
|
| 528 |
This is one of the followings: |
| 529 |
|
| 530 |
* ``scalar``: :doc:`/reference/columns/scalar` |
| 531 |
* ``vector``: :doc:`/reference/columns/vector` |
| 532 |
* ``index``: :doc:`/reference/columns/index` |
| 533 |
* - ``value_type`` |
| 534 |
- The type of the column's value. |
| 535 |
|
| 536 |
This is an object that has the following properties: |
| 537 |
|
| 538 |
* ``name``: The type name. |
| 539 |
* ``type``: ``reference`` if the type is an table, ``type`` |
| 540 |
otherwise. |
| 541 |
* - ``compress`` |
| 542 |
- The compression method of the column. |
| 543 |
|
| 544 |
If the column doesn't use any compression methods, this is |
| 545 |
``null``. |
| 546 |
|
| 547 |
If the column uses a compression method, this is one of the |
| 548 |
followings: |
| 549 |
|
| 550 |
* ``zlib``: The column uses zlib to compress column value. |
| 551 |
* ``lz4``: The column uses LZ4 to compress column value. |
| 552 |
* - ``section`` |
| 553 |
- Whether the column can store section information or not. |
| 554 |
|
| 555 |
``true`` if the column is created with ``WITH_SECTION`` flag, |
| 556 |
``false`` otherwise. |
| 557 |
|
| 558 |
Normally, if the column isn't an index column, this is ``false``. |
| 559 |
* - ``weight`` |
| 560 |
- Whether the column can store weight information or not. |
| 561 |
|
| 562 |
``true`` if the column is created with ``WITH_WEIGHT`` flag, |
| 563 |
``false`` otherwise. |
| 564 |
* - ``position`` |
| 565 |
- Whether the column can store position information or not. |
| 566 |
|
| 567 |
``true`` if the column is created with ``WITH_POSITION`` flag, |
| 568 |
``false`` otherwise. |
| 569 |
|
| 570 |
Normally, if the column isn't an index column, this is ``false``. |
| 571 |
* - ``sources`` |
| 572 |
- The source columns of the index column. |
| 573 |
|
| 574 |
This is an array of :ref:`schema-return-value-source`. |
| 575 |
|
| 576 |
If the column is an index column or a :ref:`generated-column`, |
| 577 |
this has one or more elements. Otherwise, this is an empty |
| 578 |
array. |
| 579 |
* - ``generator`` |
| 580 |
- .. versionadded:: 14.1.0 |
| 581 |
|
| 582 |
The generator expression in :doc:`../grn_expr/script_syntax`. |
| 583 |
|
| 584 |
If the column is not a :ref:`generated-column`, this is an |
| 585 |
empty string. |
| 586 |
* - ``indexes`` |
| 587 |
- The indexes of the column. |
| 588 |
|
| 589 |
This is an array of :ref:`schema-return-value-index`. |
| 590 |
* - ``command`` |
| 591 |
- The Groonga command information to create the column. |
| 592 |
|
| 593 |
This is :ref:`schema-return-value-command`. |
| 594 |
|
| 595 |
.. _schema-return-value-source: |
| 596 |
|
| 597 |
``SOURCE`` |
| 598 |
^^^^^^^^^^ |
| 599 |
|
| 600 |
``SOURCE`` is an object that describes source detail:: |
| 601 |
|
| 602 |
{ |
| 603 |
"name": COLUMN_NAME, |
| 604 |
"table": TABLE_NAME, |
| 605 |
"full_name": COLUMN_NAME_WITH_TABLE_NAME |
| 606 |
} |
| 607 |
|
| 608 |
Here are properties of ``SOURCE``: |
| 609 |
|
| 610 |
.. list-table:: |
| 611 |
:header-rows: 1 |
| 612 |
|
| 613 |
* - Name |
| 614 |
- Description |
| 615 |
* - ``name`` |
| 616 |
- The source column name. |
| 617 |
|
| 618 |
For example, ``content``. |
| 619 |
|
| 620 |
This may be a ``_key`` pseudo column. |
| 621 |
* - ``table`` |
| 622 |
- The table name of the source column. |
| 623 |
|
| 624 |
For example, ``Memos``. |
| 625 |
* - ``full_name`` |
| 626 |
- The source column name with table name. |
| 627 |
|
| 628 |
For example, ``Memos.content``. |
| 629 |
|
| 630 |
See also |
| 631 |
-------- |
| 632 |
|
| 633 |
* :doc:`table_create` |
| 634 |
* :doc:`column_create` |