8.1.7. groonga-suggest-httpd

8.1.7.1. Summary

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.

8.1.7.2. Synopsis

groonga-suggest-httpd [options] database_path

8.1.7.3. Usage

8.1.7.3.1. Set up

First you need to set up database for suggestion.

8.1.7.3.2. Launch groonga-suggest-httpd

Execute groonga-suggest-httpd command:

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

8.1.7.3.3. Request to groonga-suggest-httpd

TODO

8.1.7.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.

-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.

8.1.7.5. Command line Parameters

There is one required parameter - database_path.

8.1.7.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.

8.1.7.6. GET Parameters

groonga-suggest-httpd accepts following GET parameters.

There are required parameters which depends on type of query.

8.1.7.6.1. Required parameters

Key Description 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.  

8.1.7.6.2. Required parameters for learning

Key Description 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}'

8.1.7.6.3. Required parameters for suggestion

Key Description Note
n Specify the name of dataset for suggestion This dataset name is used to calculate suggestion results

8.1.7.6.4. Optional parameter

Key Description 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}'

8.1.7.7. Return value

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

In JSON format:

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

In JSONP format:

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

TYPE

'complete', 'correct' or 'suggest'.

CANDIDATE_N

The string of candidate (UTF-8).

SCORE_N

The number of score.