# groonga - オープンソースのカラムストア機能付き全文検索エンジン

- English

### ナビゲーション

- 索引
- 次へ |
- 前へ |
- Groonga v5.0.3ドキュメント »
- 7. リファレンスマニュアル »
- 7.1. 実行ファイル »

# 7.1.8. groonga-suggest-httpd

## 7.1.8.1. 概要

groonga-suggest-httpd is a program to provide interface which accepts HTTP request and returns suggestion dataset, then saves logs for learning. groonga-suggest-httpd behaves similar in point of view of suggestion functionality, but the name of parameter is different.

## 7.1.8.2. 書式

    groonga-suggest-httpd [options] database_path

## 7.1.8.3. 使い方

### 7.1.8.3.1. 設定をする

最初に提案用のデータベースをセットアップする必要があります。

実行例:

    % groonga-suggest-create-dataset /tmp/groonga-databases/groonga-suggest-httpd query

### 7.1.8.3.2. Launch groonga-suggest-httpd

Execute groonga-suggest-httpd command:

実行例:

    % groonga-suggest-httpd /tmp/groonga-databases/groonga-suggest-httpd

After executing above command, groonga-suggest-httpd accepts HTTP request on 8080 port.

If you just want to save requests into log file, use `-l` option.

Here is the example to save log files under `logs` directory with `log` prefix for each file.:

    % groonga-suggest-httpd -l logs/log /tmp/groonga-databases/groonga-suggest-httpd

Under `logs` directory, log files such as `logYYYYmmddHHMMSS-00` are created.

### 7.1.8.3.3. Request to groonga-suggest-httpd

Here is the sample requests to learn `groonga` for `query` dataset:

    % curl 'http://localhost:8080/?i=127.0.0.1&l=query&s=92619&t=complete&q=g'
    % curl 'http://localhost:8080/?i=127.0.0.1&l=query&s=93850&t=complete&q=gr'
    % curl 'http://localhost:8080/?i=127.0.0.1&l=query&s=94293&t=complete&q=gro'
    % curl 'http://localhost:8080/?i=127.0.0.1&l=query&s=94734&t=complete&q=groo'
    % curl 'http://localhost:8080/?i=127.0.0.1&l=query&s=95147&t=complete&q=grooon'
    % curl 'http://localhost:8080/?i=127.0.0.1&l=query&s=95553&t=complete&q=groonga'
    % curl 'http://localhost:8080/?i=127.0.0.1&l=query&s=95959&t=submit&q=groonga

## 7.1.8.4. Options

`-p````,` `--port```

  Specify http server port number. The default value is 8080.

`-t````,` `--n-threads```

  Specify number of threads. The default value is 8. This option accepts 128 as the max value, but use the number of CPU cores for performance.

`-s````,` `--send-endpoint```

  Specify endpoint for sender.

`-r````,` `--receive-endpoint```

  Specify endpoint for receiver.

`-l````,` `--log-base-path```

  Specify path prefix of log.

`--n-lines-per-log-file```

  Specify the number of lines in a log file. The default value is 1,000,000.

`-d````,` `--daemon```

  Specify this option to daemonize.

`--disable-max-fd-check```

  Specify this option to disable checking max fd on start.

## 7.1.8.5. コマンドライン引数

`database_path` だけが必須の引数です。

### 7.1.8.5.1. `database_path`

Specifies the path to a Groonga database. This database must be created by groonga-suggest-create-dataset command because it executes required initialization for suggestion.

## 7.1.8.6. GETの引数

groonga-suggest-httpd accepts following GET parameters.

必須の引数があります。どれが必須かはクエリーの種類に依存します。

### 7.1.8.6.1. 必須引数

Key | 説明 | Note
--- | --- | ---
q | UTF-8 encoded string which user fills in form |
t | The type of query. The value of type must be complete, correct, suggest or submit. It also accepts multiple type of query which is concatinated by `|`. Note that `submit` is invalid value when you specify multiple type of query. |

### 7.1.8.6.2. 学習時に必須の引数

Key | 説明 | Note
--- | --- | ---
s | Elapsed time from 0:00 January 1, 1970 | Note that you need specify the value of `s` in milliseconds
i | Unique ID to distinct user | Use session ID or IP address for example
l | Specify the name of dataset for learning. It also accepts multiple dataset name which is concatinated by `|` | Note that dataset name must be matched to following regular expression `[A-Za-z ][A-Za-z0-9 ]{0,15}`

### 7.1.8.6.3. 提案時に必須の引数

Key | 説明 | Note
--- | --- | ---
n | 提案用のデータベース名を指定します。 | This dataset name is used to calculate suggestion results

### 7.1.8.6.4. 省略可能引数

Key | 説明 | Note
--- | --- | ---
callback | Specify the name of function if you prefer JSONP as response format | The name of function must be matched to reqular expression `[A-Za-z ][A-Za-z0-9 ]{0,15}`

## 7.1.8.7. 戻り値

`groonga-suggest-httpd` command returns following response in JSON or JSONP format.

JSON形式:

    {TYPE: [[CANDIDATE_1, SCORE_1], [CANDIDATE_2, SCORE_2], ... [CANDIDATE_N, SCORE_N]]}

JSONP形式:

    FUNCTION({TYPE: [[CANDIDATE_1, SCORE_1], [CANDIDATE_2, SCORE_2], ... [CANDIDATE_N, SCORE_N]]})

`TYPE`

> `complete` 、 `correct` 、 `suggest` のどれか。

`CANDIDATE_N`

> The string of candidate (UTF-8).

`SCORE_N`

> スコア。

### ナビゲーション

- 索引
- 次へ |
- 前へ |
- Groonga v5.0.3ドキュメント »
- 7. リファレンスマニュアル »
- 7.1. 実行ファイル »