| 1 |
.. -*- rst -*- |
| 2 |
|
| 3 |
.. program:: groonga |
| 4 |
|
| 5 |
``groonga`` executable file |
| 6 |
=========================== |
| 7 |
|
| 8 |
Summary |
| 9 |
------- |
| 10 |
|
| 11 |
``groonga`` executable file provides the following features: |
| 12 |
|
| 13 |
* Fulltext search server |
| 14 |
* Fulltext search shell |
| 15 |
* Client for Groonga fulltext search server |
| 16 |
|
| 17 |
Groonga can be used as a library. If you want to use Groonga as a |
| 18 |
library, you need to write a program in C, C++ and so on. Library use |
| 19 |
is useful for embedding fulltext search feature to your application, |
| 20 |
but it's not easy to use. |
| 21 |
|
| 22 |
You can use ``groonga`` executable file to get fulltext search |
| 23 |
feature. |
| 24 |
|
| 25 |
If you want to try Groonga, fulltext search shell usage is useful. You |
| 26 |
don't need any server and client. You just need one terminal. You can |
| 27 |
try Groonga like the following:: |
| 28 |
|
| 29 |
% groonga -n db |
| 30 |
> status |
| 31 |
[[0,1429687763.70845,0.000115633010864258],{"alloc_count":195,...}] |
| 32 |
> quit |
| 33 |
% |
| 34 |
|
| 35 |
If you want to create an application that has fulltext search feature, |
| 36 |
fulltext search server usage is useful. You can use Groonga as a |
| 37 |
server like RDBMS (Relational DataBase Management |
| 38 |
System). Client-server model is a popular architecture. |
| 39 |
|
| 40 |
Normally, client for Groonga fulltext server usage isn't used. |
| 41 |
|
| 42 |
|
| 43 |
Syntax |
| 44 |
------ |
| 45 |
|
| 46 |
``groonga`` executable file has the following four modes: |
| 47 |
|
| 48 |
* Standalone mode |
| 49 |
* Server mode |
| 50 |
* Daemon mode |
| 51 |
* Client mode |
| 52 |
|
| 53 |
There are common options in these modes. These common options are |
| 54 |
described later section. |
| 55 |
|
| 56 |
.. _groonga-executable-file-standalone-mode: |
| 57 |
|
| 58 |
Standalone mode |
| 59 |
^^^^^^^^^^^^^^^ |
| 60 |
|
| 61 |
In standalone mode, ``groonga`` executable file runs one or more |
| 62 |
Groonga :doc:`/reference/command` against a local Groonga database. |
| 63 |
|
| 64 |
Here is the syntax to run shell that executes Groonga command against |
| 65 |
temporary database:: |
| 66 |
|
| 67 |
groonga [options] |
| 68 |
|
| 69 |
Here is the syntax to create a new database and run shell that |
| 70 |
executes Groonga command against the new database:: |
| 71 |
|
| 72 |
groonga [options] -n DB_PATH |
| 73 |
|
| 74 |
Here is the syntax to run shell that executes Groonga command against |
| 75 |
existing database:: |
| 76 |
|
| 77 |
groonga [options] DB_PATH |
| 78 |
|
| 79 |
Here is the syntax to run Groonga command against existing database |
| 80 |
and exit:: |
| 81 |
|
| 82 |
groonga [options] DB_PATH COMMAND [command arguments] |
| 83 |
|
| 84 |
.. _groonga-executable-file-server-mode: |
| 85 |
|
| 86 |
Server mode |
| 87 |
^^^^^^^^^^^ |
| 88 |
|
| 89 |
In server mode, ``groonga`` executable file runs as a server. The |
| 90 |
server accepts connections from other processes at local machine or |
| 91 |
remote machine and executes received Groonga :doc:`/reference/command` |
| 92 |
against a local Groonga database. |
| 93 |
|
| 94 |
You can choose one protocol from :doc:`/server/http` and |
| 95 |
:doc:`/server/gqtp`. Normally, HTTP is suitable but GQTP is the |
| 96 |
default protocol. This section describes only about HTTP protocol |
| 97 |
usage. |
| 98 |
|
| 99 |
In server mode, ``groonga`` executable file runs in the foreground. If |
| 100 |
you want to run Groonga server in the background, see |
| 101 |
:ref:`groonga-executable-file-daemon-mode`. |
| 102 |
|
| 103 |
Here is the syntax to run Groonga server with temporary database:: |
| 104 |
|
| 105 |
groonga [options] --protocol http -s |
| 106 |
|
| 107 |
Here is the syntax to create a new database and run Groonga server |
| 108 |
with the new database:: |
| 109 |
|
| 110 |
groonga [options] --protocol http -s -n DB_PATH |
| 111 |
|
| 112 |
Here is the syntax to run Groonga server with existing database:: |
| 113 |
|
| 114 |
groonga [options] --protocol http -s DB_PATH |
| 115 |
|
| 116 |
.. _groonga-executable-file-daemon-mode: |
| 117 |
|
| 118 |
Daemon mode |
| 119 |
^^^^^^^^^^^ |
| 120 |
|
| 121 |
In daemon mode, ``groonga`` executable file runs as a daemon. Daemon |
| 122 |
is similar to server but it runs in the background. See |
| 123 |
:ref:`groonga-executable-file-server-mode` about server. |
| 124 |
|
| 125 |
Here is the syntax to run Groonga daemon with temporary database:: |
| 126 |
|
| 127 |
groonga [options] --protocol http -d |
| 128 |
|
| 129 |
Here is the syntax to create a new database and run Groonga daemon |
| 130 |
with the new database:: |
| 131 |
|
| 132 |
groonga [options] --protocol http -d -n DB_PATH |
| 133 |
|
| 134 |
Here is the syntax to run Groonga daemon with existing database:: |
| 135 |
|
| 136 |
groonga [options] --protocol http -d DB_PATH |
| 137 |
|
| 138 |
:option:`--pid-path` option will be useful for daemon mode. |
| 139 |
|
| 140 |
.. _groonga-executable-file-client-mode: |
| 141 |
|
| 142 |
Client mode |
| 143 |
^^^^^^^^^^^ |
| 144 |
|
| 145 |
In client mode, ``groonga`` executable file runs as a client for GQTP |
| 146 |
protocol Groonga server. Its usage is similar to |
| 147 |
:ref:`groonga-executable-file-standalone-mode`. You can run shell and |
| 148 |
execute one command. You need to specify server address instead of |
| 149 |
local database. |
| 150 |
|
| 151 |
Note that you can't use ``groonga`` executable file as a client for |
| 152 |
Groonga server that uses HTTP. |
| 153 |
|
| 154 |
Here is the syntax to run shell that executes Groonga command against |
| 155 |
Groonga server that is running at ``192.168.0.1:10043``:: |
| 156 |
|
| 157 |
groonga [options] -c --port 10043 192.168.0.1 |
| 158 |
|
| 159 |
Here is the syntax to run Groonga command against Groonga server that |
| 160 |
is running at ``192.168.0.1:10043`` and exit:: |
| 161 |
|
| 162 |
groonga [options] -c --port 10043 192.168.0.1 COMMAND [command arguments] |
| 163 |
|
| 164 |
Options |
| 165 |
------- |
| 166 |
|
| 167 |
.. option:: -n |
| 168 |
|
| 169 |
Creates new database. |
| 170 |
|
| 171 |
.. option:: -c |
| 172 |
|
| 173 |
Executes ``groonga`` command in client mode. |
| 174 |
|
| 175 |
.. option:: -s |
| 176 |
|
| 177 |
Executes ``groonga`` command in server mode. Use "Ctrl+C" to stop the ``groonga`` process. |
| 178 |
|
| 179 |
.. option:: -d |
| 180 |
|
| 181 |
Executes ``groonga`` command in daemon mode. In contrast to server mode, ``groonga`` command forks in daemon mode. For example, to stop local daemon process, use "curl http://127.0.0.1:10041/d/shutdown". |
| 182 |
|
| 183 |
.. option:: -e, --encoding <encoding> |
| 184 |
|
| 185 |
Specifies encoding which is used for Groonga database. This option is effective when you create new Groonga database. This parameter specifies one of the following values: ``none``, ``euc``, ``utf8``, ``sjis``, ``latin`` or ``koi8r``. |
| 186 |
|
| 187 |
.. option:: -l, --log-level <log level> |
| 188 |
|
| 189 |
Specifies log level. Log level must be a log level name or an |
| 190 |
integer value. Here are available log levels: |
| 191 |
|
| 192 |
.. list-table:: |
| 193 |
:header-rows: 1 |
| 194 |
|
| 195 |
* - Log level |
| 196 |
- Name |
| 197 |
- Integer value |
| 198 |
* - None |
| 199 |
- ``none`` |
| 200 |
- ``0`` |
| 201 |
* - Emergency |
| 202 |
- ``E``, ``emerge`` or ``emergency`` |
| 203 |
- ``1`` |
| 204 |
* - Alert |
| 205 |
- ``A`` or ``alert`` |
| 206 |
- ``2`` |
| 207 |
* - Critical |
| 208 |
- ``C``, ``crit`` or ``critical`` |
| 209 |
- ``3`` |
| 210 |
* - Error |
| 211 |
- ``e`` or ``error`` |
| 212 |
- ``4`` |
| 213 |
* - Warning |
| 214 |
- ``w``, ``warn`` or ``warning`` |
| 215 |
- ``5`` |
| 216 |
* - Notice |
| 217 |
- ``n`` or ``notice`` |
| 218 |
- ``6`` |
| 219 |
* - Information |
| 220 |
- ``i`` or ``info`` |
| 221 |
- ``7`` |
| 222 |
* - Debug |
| 223 |
- ``d`` or ``debug`` |
| 224 |
- ``8`` |
| 225 |
* - Dump |
| 226 |
- ``-`` or ``dump`` |
| 227 |
- ``9`` |
| 228 |
|
| 229 |
.. option:: -a, --address <ip/hostname> |
| 230 |
|
| 231 |
.. deprecated:: 1.2.2 |
| 232 |
Use :option:`--bind-address` instead. |
| 233 |
|
| 234 |
.. option:: --bind-address <ip/hostname> |
| 235 |
|
| 236 |
.. versionadded:: 1.2.2 |
| 237 |
|
| 238 |
サーバモードかデーモンモードで実行するとき、listenするアドレスを指定します。(デフォルトは `hostname` の返すホスト名) |
| 239 |
|
| 240 |
.. option:: -p, --port <port number> |
| 241 |
|
| 242 |
クライアント、サーバ、またはデーモンモードで使用するTCPポート番号。 |
| 243 |
(クライアントモードのデフォルトは10043番、サーバ、またはデーモンモードのデフォルトは、HTTPの場合、10041番、GQTPの場合、10043番) |
| 244 |
|
| 245 |
.. option:: -i, --server-id <ip/hostname> |
| 246 |
|
| 247 |
サーバモードかデーモンモードで実行するとき、サーバのIDとなるアドレスを指定します。(デフォルトは`hostname`の返すホスト名) |
| 248 |
|
| 249 |
.. option:: -h, --help |
| 250 |
|
| 251 |
ヘルプメッセージを出力します。 |
| 252 |
|
| 253 |
.. option:: --document-root <path> |
| 254 |
|
| 255 |
httpサーバとしてgroongaを使用する場合に静的ページを格納するディレクトリを指定します。 |
| 256 |
|
| 257 |
デフォルトでは、データベースを管理するための汎用的なページに対応するファイルが/usr/share/groonga/admin_html以下にインストールされます。このディレクトリをdocument-rootオプションの値に指定して起動した場合、ウェブブラウザでhttp://hostname:port/index.htmlにアクセスすると、ウェブベースのデータベース管理ツールを使用できます。 |
| 258 |
|
| 259 |
.. option:: --protocol <protocol> |
| 260 |
|
| 261 |
http,gqtpのいずれかを指定します。(デフォルトはgqtp) |
| 262 |
|
| 263 |
.. option:: --log-path <path> |
| 264 |
|
| 265 |
ログを出力するファイルのパスを指定します。(デフォルトは/var/log/groonga/groonga.logです) |
| 266 |
|
| 267 |
.. option:: --log-flags <log flags> |
| 268 |
|
| 269 |
.. versionadded:: 8.1.1 |
| 270 |
|
| 271 |
Specify log flags. Default value is ``time|+message``. |
| 272 |
|
| 273 |
``+`` prefix means that you add a flag to the current |
| 274 |
flags. For example, ``+process_id`` means that you add the |
| 275 |
``process_id`` flag to the current flags. |
| 276 |
|
| 277 |
``-`` prefix means that you remove a flag to the current flags. For |
| 278 |
example, ``-time`` means that you remove the ``time`` flag from the |
| 279 |
current flags. |
| 280 |
|
| 281 |
No prefix means that you replace the current flags with a flag. For |
| 282 |
example, ``time|message`` equals to ``message`` because the first |
| 283 |
``time`` flag is replaced with the second ``message`` flag. |
| 284 |
|
| 285 |
Multiple log flags can be specified by separating flags with ``|``. |
| 286 |
|
| 287 |
Here are available flags: |
| 288 |
|
| 289 |
.. list-table:: |
| 290 |
:header-rows: 1 |
| 291 |
|
| 292 |
* - Name |
| 293 |
- Description |
| 294 |
* - ``none`` |
| 295 |
- Output nothing into the log. |
| 296 |
* - ``time`` |
| 297 |
- Output timestamp into the log. |
| 298 |
* - ``message`` |
| 299 |
- Output message into the log. |
| 300 |
* - ``location`` |
| 301 |
- Output process ID and a location of an output of the log |
| 302 |
(file name, line and function name) into the log. |
| 303 |
* - ``process_id`` |
| 304 |
- Output process ID into the log. |
| 305 |
* - ``pid`` |
| 306 |
- This flag is an alias of ``process_id``. |
| 307 |
* - ``thread_id`` |
| 308 |
- Output thread ID into log. |
| 309 |
* - ``context_id`` |
| 310 |
- .. versionadded:: 14.1.1 |
| 311 |
|
| 312 |
Output context ID into log. |
| 313 |
|
| 314 |
Context ID is logged in :ref:`query-log` too. So this is |
| 315 |
useful to associate logs of the same context in |
| 316 |
:ref:`process-log` and :ref:`query-log`. |
| 317 |
* - ``all`` |
| 318 |
- This flag specifies all flags except ``none`` and ``default`` |
| 319 |
flags. |
| 320 |
* - ``default`` |
| 321 |
- This equals to ``time|+message``. |
| 322 |
|
| 323 |
.. option:: --log-rotate-threshold-size <threshold> |
| 324 |
|
| 325 |
.. versionadded:: 5.0.3 |
| 326 |
|
| 327 |
Specifies threshold for log rotation. Log file is rotated when log file size is larger than or equals to the threshold (default: 0; disabled). |
| 328 |
|
| 329 |
.. option:: --query-log-path <path> |
| 330 |
|
| 331 |
クエリーログを出力するファイルのパスを指定します。(デフォルトでは出力されません) |
| 332 |
|
| 333 |
.. option:: --query-log-rotate-threshold-size <threshold> |
| 334 |
|
| 335 |
.. versionadded:: 5.0.3 |
| 336 |
|
| 337 |
Specifies threshold for query log rotation. Query log file is rotated when query log file size is larger than or equals to the threshold (default: 0; disabled). |
| 338 |
|
| 339 |
.. option:: -t, --max-threads <max threads> |
| 340 |
|
| 341 |
最大で利用するスレッド数を指定します。(デフォルトはマシンのCPUコア数と同じ数です) |
| 342 |
|
| 343 |
.. option:: --pid-path <path> |
| 344 |
|
| 345 |
PIDを保存するパスを指定します。(デフォルトでは保存しません) |
| 346 |
|
| 347 |
.. option:: --config-path <path> |
| 348 |
|
| 349 |
設定ファイルのパスを指定します。設定ファイルは以下のようなフォーマットになります。:: |
| 350 |
|
| 351 |
# '#'以降はコメント。 |
| 352 |
; ';'以降もコメント。 |
| 353 |
|
| 354 |
# 'キー = 値'でオプションを指定。 |
| 355 |
pid-path = /var/run/groonga.pid |
| 356 |
|
| 357 |
# '='の前後の空白はは無視される。↓は↑と同じ意味。 |
| 358 |
pid-path=/var/run/groonga.pid |
| 359 |
|
| 360 |
# 'キー'は'--XXX'スタイルのオプション名と同じものが使える。 |
| 361 |
# 例えば、'--pid-path'に対応するキーは'pid-path'。 |
| 362 |
# ただし、キーが'config-path'のオプションは無視される。 |
| 363 |
|
| 364 |
.. option:: --cache-limit <limit> |
| 365 |
|
| 366 |
キャッシュ数の最大値を指定します。(デフォルトは100です) |
| 367 |
|
| 368 |
.. option:: --default-match-escalation-threshold <threshold> |
| 369 |
|
| 370 |
検索の挙動をエスカレーションする閾値を指定します。(デフォルトは0です) |
| 371 |
|
| 372 |
.. option:: --default-n-workers <n> |
| 373 |
|
| 374 |
.. versionadded:: 14.0.7 |
| 375 |
|
| 376 |
Specifies the default number of workers of the Groonga process. For example, it's used by the default value of ``n_workers`` of :doc:`/reference/commands/select`. |
| 377 |
|
| 378 |
The default value is ``0``. |
| 379 |
|
| 380 |
.. option:: --default-request-timeout <timeout> |
| 381 |
|
| 382 |
Specifies the default request timeout in seconds. |
| 383 |
|
| 384 |
You can specify timeout less than 1 second by decimal such as |
| 385 |
``0.1``. ``0.1`` means that 100 milliseconds. |
| 386 |
|
| 387 |
If you specify ``0`` or less value, request timeout is disabled by |
| 388 |
default. |
| 389 |
|
| 390 |
The default value is ``0``. |
| 391 |
|
| 392 |
.. seealso:: :doc:`/reference/command/request_timeout` |
| 393 |
|
| 394 |
.. option:: --cache-base-path <path> |
| 395 |
|
| 396 |
.. versionadded:: 7.0.2 |
| 397 |
|
| 398 |
Specifies the base path for cache. It enables persistent cache |
| 399 |
feature. |
| 400 |
|
| 401 |
You can get the following merits by persistent cache feature: |
| 402 |
|
| 403 |
* You can reuse cache after ``groonga`` process is restarted. You |
| 404 |
don't need to warm up your cache each restart. |
| 405 |
|
| 406 |
* You can share cache with multiple ``groonga`` processes. |
| 407 |
|
| 408 |
You must specify the base path on memory file system. If you |
| 409 |
specify the base path on disk, your cache will be slow. It's not |
| 410 |
make sense. |
| 411 |
|
| 412 |
The default is nothing. It means that persistent cache is |
| 413 |
disabled. On memory cache is used. |
| 414 |
|
| 415 |
Persistent cache is a bit slower than on memory cache. Normally, |
| 416 |
the difference has little influence on performance. |
| 417 |
|
| 418 |
Command line parameters |
| 419 |
----------------------- |
| 420 |
|
| 421 |
.. option:: dest |
| 422 |
|
| 423 |
使用するデータベースのパス名を指定します。 |
| 424 |
|
| 425 |
クライアントモードの場合は接続先のホスト名とポート番号を指定します(デフォルト値は'localhost:10043')。ポート番号を指定しない場合には、10043が指定されたものとします。 |
| 426 |
|
| 427 |
.. option:: command [args] |
| 428 |
|
| 429 |
スタンドアロンおよびクライアントモードの場合は、実行するコマンドとその引数をコマンドライン引数に指定できます。コマンドライン引数にcommandを与えなかった場合は、標準入力から一行ずつEOFに達するまでコマンド文字列を読み取り、順次実行します。 |
| 430 |
|
| 431 |
.. _command-list-with-continuous-line: |
| 432 |
|
| 433 |
Command |
| 434 |
------- |
| 435 |
|
| 436 |
groongaコマンドを通してデータベースを操作する命令をコマンドと呼びます。コマンドは主にC言語で記述され、groongaプロセスにロードすることによって使用できるようになります。 |
| 437 |
それぞれのコマンドは一意な名前と、0個以上の引数を持ちます。 |
| 438 |
|
| 439 |
引数は以下の2種類の方法のいずれかで指定することができます。:: |
| 440 |
|
| 441 |
形式1: コマンド名 値1 値2,.. |
| 442 |
|
| 443 |
形式2: コマンド名 --引数名1 値1 --引数名2 値2,.. |
| 444 |
|
| 445 |
形式1でコマンドを実行する場合は、定義された順番で値を指定しなければならず、途中の引数の値を省略することはできません。形式2でコマンドを実行する場合は、「--引数名」のように引数の名前を明示しなければならない代わりに、任意の順番で引数を指定することが可能で、途中の引数の指定を省略することもできます。 |
| 446 |
|
| 447 |
標準入力からコマンド文字列を与える場合は、コマンド名と引数名と値は、空白( )で区切ります。空白や、記号「"'()\」のうちいずれかを含む値を指定したい場合は、シングルクォート(')かダブルクォート(")で値を囲みます。値として指定する文字列の中では、改行文字は'\n'に置き換えて指定します。また、引用符に使用した文字を値の中で指定する場合には、その文字の前にバックスラッシュ('\') を指定します。バックスラッシュ文字自身を値として指定する場合には、その前にバックスラッシュを指定します。 |
| 448 |
|
| 449 |
You can write command list with continuous line which is represented by '\\' character.:: |
| 450 |
|
| 451 |
table_create --name Terms \ |
| 452 |
--flags TABLE_PAT_KEY \ |
| 453 |
--key_type ShortText \ |
| 454 |
--default_tokenizer TokenBigram |
| 455 |
|
| 456 |
Builtin command |
| 457 |
--------------- |
| 458 |
|
| 459 |
以下のコマンドは組み込みコマンドとして予め定義されています。 |
| 460 |
|
| 461 |
``status`` |
| 462 |
groongaプロセスの状態を表示します。 |
| 463 |
|
| 464 |
``table_list`` |
| 465 |
DBに定義されているテーブルのリストを表示します。 |
| 466 |
|
| 467 |
``column_list`` |
| 468 |
テーブルに定義されているカラムのリストを表示します。 |
| 469 |
|
| 470 |
``table_create`` |
| 471 |
DBにテーブルを追加します。 |
| 472 |
|
| 473 |
``column_create`` |
| 474 |
テーブルにカラムを追加します。 |
| 475 |
|
| 476 |
``table_remove`` |
| 477 |
DBに定義されているテーブルを削除します。 |
| 478 |
|
| 479 |
``column_remove`` |
| 480 |
テーブルに定義されているカラムを削除します。 |
| 481 |
|
| 482 |
``load`` |
| 483 |
テーブルにレコードを挿入します。 |
| 484 |
|
| 485 |
``select`` |
| 486 |
テーブルに含まれるレコードを検索して表示します。 |
| 487 |
|
| 488 |
``define_selector`` |
| 489 |
検索条件をカスタマイズした新たな検索コマンドを定義します。 |
| 490 |
|
| 491 |
``quit`` |
| 492 |
データベースとのセッションを終了します。 |
| 493 |
|
| 494 |
``shutdown`` |
| 495 |
サーバ(デーモン)プロセスを停止します。 |
| 496 |
|
| 497 |
``log_level`` |
| 498 |
ログ出力レベルを設定します。 |
| 499 |
|
| 500 |
``log_put`` |
| 501 |
ログ出力を行います。 |
| 502 |
|
| 503 |
``clearlock`` |
| 504 |
ロックを解除します。 |
| 505 |
|
| 506 |
|
| 507 |
Usage |
| 508 |
----- |
| 509 |
|
| 510 |
新しいデータベースを作成します。:: |
| 511 |
|
| 512 |
% groonga -n /tmp/hoge.db quit |
| 513 |
% |
| 514 |
|
| 515 |
作成済みのデータベースにテーブルを定義します。:: |
| 516 |
|
| 517 |
% groonga /tmp/hoge.db table_create Table 0 ShortText |
| 518 |
[[0]] |
| 519 |
% |
| 520 |
|
| 521 |
サーバを起動します。:: |
| 522 |
|
| 523 |
% groonga -d /tmp/hoge.db |
| 524 |
% |
| 525 |
|
| 526 |
httpサーバとして起動します。:: |
| 527 |
|
| 528 |
% groonga -d -p 80 --protocol http --document-root /usr/share/groonga/admin_html /tmp/hoge.db |
| 529 |
% |
| 530 |
|
| 531 |
サーバに接続し、テーブル一覧を表示します。:: |
| 532 |
|
| 533 |
% groonga -c localhost table_list |
| 534 |
[[0],[["id","name","path","flags","domain"],[256,"Table","/tmp/hoge.db.0000100",49152,14]]] |
| 535 |
% |