File: groonga-suggest-httpd.html

package info (click to toggle)
groonga 11.0.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 121,576 kB
  • sloc: ansic: 801,209; javascript: 62,121; ruby: 46,206; cpp: 33,790; xml: 24,951; yacc: 13,333; sh: 7,776; python: 3,266; makefile: 2,315; perl: 133
file content (685 lines) | stat: -rw-r--r-- 44,721 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685


<!DOCTYPE html>

<html lang="en">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>7.1.8. groonga-suggest-httpd &#8212; Groonga v10.1.1-31-g1e46ba6 documentation</title>
    <link rel="stylesheet" href="../../_static/groonga.css" type="text/css" />
    <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
    
    <script id="documentation_options" data-url_root="../../" src="../../_static/documentation_options.js"></script>
    <script src="../../_static/jquery.js"></script>
    <script src="../../_static/underscore.js"></script>
    <script src="../../_static/doctools.js"></script>
    <script src="../../_static/language_data.js"></script>
    
    <link rel="shortcut icon" href="../../_static/favicon.ico"/>
    <link rel="index" title="Index" href="../../genindex.html" />
    <link rel="search" title="Search" href="../../search.html" />
    <link rel="next" title="7.1.9. groonga-suggest-learner" href="groonga-suggest-learner.html" />
    <link rel="prev" title="7.1.7. groonga-suggest-create-dataset" href="groonga-suggest-create-dataset.html" /> 
  </head><body>
<div class="header">
  <h1 class="title">
    <a id="top-link" href="../../index.html">
      <span class="project">groonga</span>
      <span class="separator">-</span>
      <span class="description">An open-source fulltext search engine and column store.</span>
    </a>
  </h1>

  <div class="other-language-links">
    <ul>
      <li><a href="../../../../ja/html/reference/executables/groonga-suggest-httpd.html">日本語</a></li>
    </ul>
  </div>
</div>
  

    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="groonga-suggest-learner.html" title="7.1.9. groonga-suggest-learner"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="groonga-suggest-create-dataset.html" title="7.1.7. groonga-suggest-create-dataset"
             accesskey="P">previous</a> |</li>
        <li class="nav-item nav-item-0"><a href="../../index.html">Groonga v10.1.1-31-g1e46ba6 documentation</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="../../reference.html" ><span class="section-number">7. </span>Reference manual</a> &#187;</li>
          <li class="nav-item nav-item-2"><a href="../executables.html" accesskey="U"><span class="section-number">7.1. </span>Executables</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href=""><span class="section-number">7.1.8. </span><code class="docutils literal notranslate"><span class="pre">groonga-suggest-httpd</span></code></a></li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body" role="main">
            
  <div class="section" id="groonga-suggest-httpd">
<h1><span class="section-number">7.1.8. </span><code class="docutils literal notranslate"><span class="pre">groonga-suggest-httpd</span></code><a class="headerlink" href="#groonga-suggest-httpd" title="Permalink to this headline">¶</a></h1>
<div class="section" id="summary">
<h2><span class="section-number">7.1.8.1. </span>Summary<a class="headerlink" href="#summary" title="Permalink to this headline">¶</a></h2>
<p><code class="docutils literal notranslate"><span class="pre">groonga-suggest-httpd</span></code> is a program that provides HTTP interface
for the following features:</p>
<blockquote>
<div><ul class="simple">
<li><p>Returning <a class="reference internal" href="../suggest.html"><span class="doc">Suggest</span></a> execution result</p></li>
<li><p>Saving logs for learning</p></li>
</ul>
</div></blockquote>
<p><code class="docutils literal notranslate"><span class="pre">groonga-suggest-httpd</span></code> provides suggest feature like
<a class="reference internal" href="../commands/suggest.html"><span class="doc">suggest</span></a> command. Note that some parameter
names are different of them.</p>
</div>
<div class="section" id="syntax">
<h2><span class="section-number">7.1.8.2. </span>Syntax<a class="headerlink" href="#syntax" title="Permalink to this headline">¶</a></h2>
<p><code class="docutils literal notranslate"><span class="pre">groonga-suggest-httpd</span></code> requires database path:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>groonga-suggest-httpd [options] DATABASE_PATH
</pre></div>
</div>
</div>
<div class="section" id="usage">
<h2><span class="section-number">7.1.8.3. </span>Usage<a class="headerlink" href="#usage" title="Permalink to this headline">¶</a></h2>
<p>You need to create one or more datasets to use
<code class="docutils literal notranslate"><span class="pre">groonga-suggest-httpd</span></code>. A dataset consists of tables and
columns. You can define them by <a class="reference internal" href="groonga-suggest-create-dataset.html"><span class="doc">groonga-suggest-create-dataset</span></a>.</p>
<p>You need to use <a class="reference internal" href="groonga-suggest-learner.html"><span class="doc">groonga-suggest-learner</span></a> to learn suggestion
data from user inputs. You doesn’t need to use
<a class="reference internal" href="groonga-suggest-learner.html"><span class="doc">groonga-suggest-learner</span></a> when you create suggestion data by
hand. See <a class="reference internal" href="../suggest.html"><span class="doc">Suggest</span></a> and sub documents about creating
suggestion data by hand.</p>
<p>You can use <code class="docutils literal notranslate"><span class="pre">groonga-suggest-httpd</span></code> via HTTP after you create one or
more datasets.</p>
<p>The following sections describes the followings:</p>
<blockquote>
<div><ul class="simple">
<li><p>How to set up a dataset</p></li>
<li><p>How to use <code class="docutils literal notranslate"><span class="pre">groonga-suggest-httpd</span></code> with <a class="reference internal" href="groonga-suggest-learner.html"><span class="doc">groonga-suggest-learner</span></a></p></li>
<li><p>How to use <code class="docutils literal notranslate"><span class="pre">groonga-suggest-httpd</span></code> for retrieving suggestions.</p></li>
</ul>
</div></blockquote>
<div class="section" id="setup">
<h3><span class="section-number">7.1.8.3.1. </span>Setup<a class="headerlink" href="#setup" title="Permalink to this headline">¶</a></h3>
<p>You need to create a dataset by <a class="reference internal" href="groonga-suggest-create-dataset.html"><span class="doc">groonga-suggest-create-dataset</span></a>.</p>
<p>Here is an example that creates <code class="docutils literal notranslate"><span class="pre">query</span></code> dataset:</p>
<p>Execution example:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>% groonga-suggest-create-dataset ${DB_PATH} query
&gt; plugin_register suggest/suggest
false
&gt; table_create event_type TABLE_HASH_KEY ShortText
true
&gt; table_create bigram TABLE_PAT_KEY ShortText --default_tokenizer TokenBigram --normalizer NormalizerAuto
true
&gt; table_create kana TABLE_PAT_KEY ShortText --normalizer NormalizerAuto
true
&gt; table_create item_query TABLE_PAT_KEY ShortText --default_tokenizer TokenDelimit --normalizer NormalizerAuto
true
&gt; column_create bigram item_query_key COLUMN_INDEX|WITH_POSITION item_query _key
true
&gt; column_create item_query kana COLUMN_VECTOR kana
true
&gt; column_create kana item_query_kana COLUMN_INDEX item_query kana
true
&gt; column_create item_query freq COLUMN_SCALAR Int32
true
&gt; column_create item_query last COLUMN_SCALAR Time
true
&gt; column_create item_query boost COLUMN_SCALAR Int32
true
&gt; column_create item_query freq2 COLUMN_SCALAR Int32
true
&gt; column_create item_query buzz COLUMN_SCALAR Int32
true
&gt; table_create pair_query TABLE_HASH_KEY UInt64
true
&gt; column_create pair_query pre COLUMN_SCALAR item_query
true
&gt; column_create pair_query post COLUMN_SCALAR item_query
true
&gt; column_create pair_query freq0 COLUMN_SCALAR Int32
true
&gt; column_create pair_query freq1 COLUMN_SCALAR Int32
true
&gt; column_create pair_query freq2 COLUMN_SCALAR Int32
true
&gt; column_create item_query co COLUMN_INDEX pair_query pre
true
&gt; table_create sequence_query TABLE_HASH_KEY ShortText
true
&gt; table_create event_query TABLE_NO_KEY
true
&gt; column_create sequence_query events COLUMN_VECTOR|RING_BUFFER event_query
true
&gt; column_create event_query type COLUMN_SCALAR event_type
true
&gt; column_create event_query time COLUMN_SCALAR Time
true
&gt; column_create event_query item COLUMN_SCALAR item_query
true
&gt; column_create event_query sequence COLUMN_SCALAR sequence_query
true
&gt; table_create configuration TABLE_HASH_KEY ShortText
true
&gt; column_create configuration weight COLUMN_SCALAR UInt32
true
&gt; load --table configuration
&gt; [
&gt; {&quot;_key&quot;: &quot;query&quot;, &quot;weight&quot;: 1}
&gt; ]
1
</pre></div>
</div>
<p><a class="reference internal" href="groonga-suggest-create-dataset.html"><span class="doc">groonga-suggest-create-dataset</span></a> outputs executed commands. You
can confirm that what tables and columns are created for the new
dataset.</p>
</div>
<div class="section" id="launch-groonga-suggest-learner">
<h3><span class="section-number">7.1.8.3.2. </span>Launch <code class="docutils literal notranslate"><span class="pre">groonga-suggest-learner</span></code><a class="headerlink" href="#launch-groonga-suggest-learner" title="Permalink to this headline">¶</a></h3>
<p>You can choose whether you use learned suggestion data immediately or
not.</p>
<p>There are two ways to use learned suggestion data immediately:</p>
<blockquote>
<div><ul class="simple">
<li><p>Both of <code class="docutils literal notranslate"><span class="pre">groonga-suggest-httpd</span></code> and
<a class="reference internal" href="groonga-suggest-learner.html"><span class="doc">groonga-suggest-learner</span></a> use the same database</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">groonga-suggest-httpd</span></code> receives learned suggestion data from
<a class="reference internal" href="groonga-suggest-learner.html"><span class="doc">groonga-suggest-learner</span></a></p></li>
</ul>
</div></blockquote>
<p>In the former case, you must run both <code class="docutils literal notranslate"><span class="pre">groonga-suggest-httpd</span></code> and
<a class="reference internal" href="groonga-suggest-learner.html"><span class="doc">groonga-suggest-learner</span></a> on the same host.</p>
<p>In the latter case, you can run <code class="docutils literal notranslate"><span class="pre">groonga-suggest-httpd</span></code> and
<a class="reference internal" href="groonga-suggest-learner.html"><span class="doc">groonga-suggest-learner</span></a> on different hosts.</p>
<p>If you don’t need to use learned suggestion data immediately, you need
to apply learned suggestion data from database that is used by
<a class="reference internal" href="groonga-suggest-learner.html"><span class="doc">groonga-suggest-learner</span></a> to database that is used by
<code class="docutils literal notranslate"><span class="pre">groonga-suggest-httpd</span></code> by hand. Normally, this usage is
recommended. Because learned suggestion data may have garbage data by
inputs from evil users.</p>
<p>In this document, learned suggestion data are used immediately by
receiving learned suggestion data from
<a class="reference internal" href="groonga-suggest-learner.html"><span class="doc">groonga-suggest-learner</span></a>. Both <code class="docutils literal notranslate"><span class="pre">groonga-suggest-httpd</span></code> and
<a class="reference internal" href="groonga-suggest-learner.html"><span class="doc">groonga-suggest-learner</span></a> are running on the same host. Because
it’s easy to explain.</p>
<p>Here is an example that launches <a class="reference internal" href="groonga-suggest-learner.html"><span class="doc">groonga-suggest-learner</span></a>. You
need to specify database that has <code class="docutils literal notranslate"><span class="pre">query</span></code> dataset. This document
omits the instruction for creating <code class="docutils literal notranslate"><span class="pre">query</span></code> dataset:</p>
<p>Execution example:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>% groonga-suggest-learner --daemon ${DB_PATH}
</pre></div>
</div>
<p>The <code class="docutils literal notranslate"><span class="pre">groonga-suggest-learner</span></code> process opens two endpoints at
<code class="docutils literal notranslate"><span class="pre">1234</span></code> port and <code class="docutils literal notranslate"><span class="pre">1235</span></code> port:</p>
<blockquote>
<div><ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">1234</span></code> port: Endpoint that accepts user input data from
<code class="docutils literal notranslate"><span class="pre">groonga-suggest-httpd</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">1235</span></code> port: Endpoint that sends learned suggestion data to
<code class="docutils literal notranslate"><span class="pre">groonga-suggest-httpd</span></code></p></li>
</ul>
</div></blockquote>
</div>
<div class="section" id="launch-groonga-suggest-httpd">
<h3><span class="section-number">7.1.8.3.3. </span>Launch <code class="docutils literal notranslate"><span class="pre">groonga-suggest-httpd</span></code><a class="headerlink" href="#launch-groonga-suggest-httpd" title="Permalink to this headline">¶</a></h3>
<p>You need to launch <code class="docutils literal notranslate"><span class="pre">groonga-suggest-httpd</span></code> for the following proposes:</p>
<blockquote>
<div><ul class="simple">
<li><p>Learning suggestion data from user inputs</p></li>
<li><p>Providing suggestion result to clients</p></li>
</ul>
</div></blockquote>
<p>Here is an example that launches <code class="docutils literal notranslate"><span class="pre">groonga-suggest-httpd</span></code> that
communicates <a class="reference internal" href="groonga-suggest-learner.html"><span class="doc">groonga-suggest-learner</span></a>:</p>
<p>Execution example:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>% groonga-suggest-httpd --send-endpoint &#39;tcp://127.0.0.1:1234&#39; --receive-endpoint &#39;tcp://127.0.0.1:1235&#39; --daemon ${DB_PATH}
</pre></div>
</div>
<p>The <code class="docutils literal notranslate"><span class="pre">groonga-suggest-httpd</span></code> process accepts HTTP requests on
<code class="docutils literal notranslate"><span class="pre">8080</span></code> port.</p>
<p>If you want to save requests into log file, use
<a class="reference internal" href="#cmdoption-groonga-suggest-httpd-l"><code class="xref std std-option docutils literal notranslate"><span class="pre">--log-base-path</span></code></a> option.</p>
<p>Here is an example to save log files under <code class="docutils literal notranslate"><span class="pre">logs</span></code> directory with
<code class="docutils literal notranslate"><span class="pre">log</span></code> prefix for each file:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>% groonga-suggest-httpd --log-base-path logs/log ${DB_PATH}
</pre></div>
</div>
<p><code class="docutils literal notranslate"><span class="pre">groonga-suggest-httpd</span></code> creates log files such as
<code class="docutils literal notranslate"><span class="pre">logYYYYmmddHHMMSS-00</span></code> under <code class="docutils literal notranslate"><span class="pre">logs</span></code> directory.</p>
</div>
<div class="section" id="learn-from-user-inputs">
<h3><span class="section-number">7.1.8.3.4. </span>Learn from user inputs<a class="headerlink" href="#learn-from-user-inputs" title="Permalink to this headline">¶</a></h3>
<p>You can learn suggestion data from user inputs.</p>
<p>You need to specify the following parameters to learn suggestion data:</p>
<blockquote>
<div><ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">i</span></code>: The ID of the user (You may use IP address of client)</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">l</span></code>: The dataset name</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">s</span></code>: The timestamp of the input in seconds</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">t</span></code>: The query type (It’s optional. You must specify <code class="docutils literal notranslate"><span class="pre">submit</span></code> only when the user input is submitted.)</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">q</span></code>: The user input</p></li>
</ul>
</div></blockquote>
<p>Here are example requests to learn user input “Groonga” in <code class="docutils literal notranslate"><span class="pre">query</span></code>
dataset:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>.. groonga-command
.. include:: ../../example/reference/executables/groonga-suggest-httpd/learn.log
.. % curl &#39;http://localhost:8080/?i=127.0.0.1&amp;l=query&amp;s=92619&amp;q=G&#39;
.. % curl &#39;http://localhost:8080/?i=127.0.0.1&amp;l=query&amp;s=93850&amp;q=Gr&#39;
.. % curl &#39;http://localhost:8080/?i=127.0.0.1&amp;l=query&amp;s=94293&amp;q=Gro&#39;
.. % curl &#39;http://localhost:8080/?i=127.0.0.1&amp;l=query&amp;s=94734&amp;q=Groo&#39;
.. % curl &#39;http://localhost:8080/?i=127.0.0.1&amp;l=query&amp;s=95147&amp;q=Grooon&#39;
.. % curl &#39;http://localhost:8080/?i=127.0.0.1&amp;l=query&amp;s=95553&amp;q=Groonga&#39;
.. % curl &#39;http://localhost:8080/?i=127.0.0.1&amp;l=query&amp;s=95959&amp;t=submit&amp;q=Groonga&#39;
</pre></div>
</div>
<p>Inputting data must not use <code class="docutils literal notranslate"><span class="pre">t=submit</span></code> parameter. In the above example, you just learn user inputs but you can learn and get complete candidates at once. It’s described at the next section.</p>
<p>Submitted data must use <code class="docutils literal notranslate"><span class="pre">t=submit</span></code> parameter.</p>
</div>
<div class="section" id="use-suggested-response">
<h3><span class="section-number">7.1.8.3.5. </span>Use suggested response<a class="headerlink" href="#use-suggested-response" title="Permalink to this headline">¶</a></h3>
<p>You can get suggested result from <code class="docutils literal notranslate"><span class="pre">groonga-suggest-httpd</span></code>.</p>
<p>You need to specify the following parameters to get suggested result:</p>
<blockquote>
<div><ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">n</span></code>: The dataset name</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">t</span></code>: The query type (<code class="docutils literal notranslate"><span class="pre">complete</span></code>, <code class="docutils literal notranslate"><span class="pre">correct</span></code> and/or <code class="docutils literal notranslate"><span class="pre">suggest</span></code>)</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">q</span></code>: The user input</p></li>
</ul>
</div></blockquote>
<p>You can also specify parameters for <a class="reference internal" href="../commands/suggest.html"><span class="doc">suggest</span></a> as option.</p>
<p>Here is an example that gets <a class="reference internal" href="../suggest/completion.html"><span class="doc">Completion</span></a> result. The result is computed by using learned data at the previous section. <code class="docutils literal notranslate"><span class="pre">frequency_threshold=1</span></code> parameter is used because this is an example. The parameter enables input data that are occurred one or more times. Normally, you should not use the parameter for production. The parameter will increase noises:</p>
<p>Execution example:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>% curl &#39;http://localhost:8080/?n=query&amp;t=complete&amp;q=G&amp;frequency_threshold=1&#39;
</pre></div>
</div>
<p>You can combine completion and learning by specifying parameters for both:</p>
<p>Execution example:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>% curl &#39;http://localhost:8080/?i=127.0.0.1&amp;l=query&amp;s=96000&amp;q=G&amp;n=query&amp;t=complete&amp;frequency_threshold=1&#39;
</pre></div>
</div>
</div>
</div>
<div class="section" id="command-line-parameters">
<h2><span class="section-number">7.1.8.4. </span>Command line parameters<a class="headerlink" href="#command-line-parameters" title="Permalink to this headline">¶</a></h2>
<div class="section" id="required-parameters">
<h3><span class="section-number">7.1.8.4.1. </span>Required parameters<a class="headerlink" href="#required-parameters" title="Permalink to this headline">¶</a></h3>
<p>There is only one required parameter.</p>
<div class="section" id="database-path">
<h4><span class="section-number">7.1.8.4.1.1. </span><code class="docutils literal notranslate"><span class="pre">DATABASE_PATH</span></code><a class="headerlink" href="#database-path" title="Permalink to this headline">¶</a></h4>
<p>Specifies the path to a Groonga database. This database must have one
or more datasets. Each dataset must be created by
<a class="reference internal" href="groonga-suggest-create-dataset.html"><span class="doc">groonga-suggest-create-dataset</span></a>.</p>
</div>
</div>
<div class="section" id="optional-parameters">
<h3><span class="section-number">7.1.8.4.2. </span>Optional parameters<a class="headerlink" href="#optional-parameters" title="Permalink to this headline">¶</a></h3>
<dl class="std option">
<dt id="cmdoption-groonga-suggest-httpd-p">
<span id="cmdoption-groonga-suggest-httpd-port"></span><code class="sig-name descname">-p</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--port</code><code class="sig-prename descclassname"></code><a class="headerlink" href="#cmdoption-groonga-suggest-httpd-p" title="Permalink to this definition">¶</a></dt>
<dd><p>Specify HTTP server port number.</p>
<p>The default port number is <code class="docutils literal notranslate"><span class="pre">8080</span></code>.</p>
</dd></dl>

<dl class="std option">
<dt id="cmdoption-groonga-suggest-httpd-t">
<span id="cmdoption-groonga-suggest-httpd-n-threads"></span><code class="sig-name descname">-t</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--n-threads</code><code class="sig-prename descclassname"></code><a class="headerlink" href="#cmdoption-groonga-suggest-httpd-t" title="Permalink to this definition">¶</a></dt>
<dd><p>Specify number of threads.</p>
<p>This option accepts <code class="docutils literal notranslate"><span class="pre">128</span></code> as the max value, but use the number of
CPU cores for performance.</p>
<p>The default value is the number of CPU cores.</p>
</dd></dl>

<dl class="std option">
<dt id="cmdoption-groonga-suggest-httpd-s">
<span id="cmdoption-groonga-suggest-httpd-send-endpoint"></span><code class="sig-name descname">-s</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--send-endpoint</code><code class="sig-prename descclassname"></code><a class="headerlink" href="#cmdoption-groonga-suggest-httpd-s" title="Permalink to this definition">¶</a></dt>
<dd><p>Specify endpoint URI of <a class="reference internal" href="groonga-suggest-learner.html"><span class="doc">groonga-suggest-learner</span></a> for sending
user inputs.</p>
<p>The format is <code class="docutils literal notranslate"><span class="pre">tcp://${HOST}:${PORT}</span></code> such as
<code class="docutils literal notranslate"><span class="pre">tcp://192.168.0.1:2929</span></code>.</p>
<p>The default value is none.</p>
</dd></dl>

<dl class="std option">
<dt id="cmdoption-groonga-suggest-httpd-r">
<span id="cmdoption-groonga-suggest-httpd-receive-endpoint"></span><code class="sig-name descname">-r</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--receive-endpoint</code><code class="sig-prename descclassname"></code><a class="headerlink" href="#cmdoption-groonga-suggest-httpd-r" title="Permalink to this definition">¶</a></dt>
<dd><p>Specify endpoint URI of <a class="reference internal" href="groonga-suggest-learner.html"><span class="doc">groonga-suggest-learner</span></a> for
receiving learned suggestion data.</p>
<p>The format is <code class="docutils literal notranslate"><span class="pre">tcp://${HOST}:${PORT}</span></code> such as
<code class="docutils literal notranslate"><span class="pre">tcp://192.168.0.1:2929</span></code>.</p>
<p>The default value is none.</p>
</dd></dl>

<dl class="std option">
<dt id="cmdoption-groonga-suggest-httpd-l">
<span id="cmdoption-groonga-suggest-httpd-log-base-path"></span><code class="sig-name descname">-l</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--log-base-path</code><code class="sig-prename descclassname"></code><a class="headerlink" href="#cmdoption-groonga-suggest-httpd-l" title="Permalink to this definition">¶</a></dt>
<dd><p>Specify path prefix of log.</p>
<p>The default value is none.</p>
</dd></dl>

<dl class="std option">
<dt id="cmdoption-groonga-suggest-httpd-n-lines-per-log-file">
<code class="sig-name descname">--n-lines-per-log-file</code><code class="sig-prename descclassname"></code><a class="headerlink" href="#cmdoption-groonga-suggest-httpd-n-lines-per-log-file" title="Permalink to this definition">¶</a></dt>
<dd><p>Specify the max number of lines in a log file.</p>
<p>The default value is <code class="docutils literal notranslate"><span class="pre">1000000</span></code>.</p>
</dd></dl>

<dl class="std option">
<dt id="cmdoption-groonga-suggest-httpd-d">
<span id="cmdoption-groonga-suggest-httpd-daemon"></span><code class="sig-name descname">-d</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--daemon</code><code class="sig-prename descclassname"></code><a class="headerlink" href="#cmdoption-groonga-suggest-httpd-d" title="Permalink to this definition">¶</a></dt>
<dd><p>Specify this option to daemonize.</p>
<p>Don’t daemonize by default.</p>
</dd></dl>

<dl class="std option">
<dt id="cmdoption-groonga-suggest-httpd-disable-max-fd-check">
<code class="sig-name descname">--disable-max-fd-check</code><code class="sig-prename descclassname"></code><a class="headerlink" href="#cmdoption-groonga-suggest-httpd-disable-max-fd-check" title="Permalink to this definition">¶</a></dt>
<dd><p>Specify this option to disable checking the max number of file
descriptors on start.</p>
<p>Check by default.</p>
</dd></dl>

</div>
</div>
<div class="section" id="get-parameters">
<h2><span class="section-number">7.1.8.5. </span>GET parameters<a class="headerlink" href="#get-parameters" title="Permalink to this headline">¶</a></h2>
<p><code class="docutils literal notranslate"><span class="pre">groonga-suggest-httpd</span></code> accepts some GET parameters.</p>
<p>There are required parameters which depend on query type.</p>
<p>In <code class="docutils literal notranslate"><span class="pre">complete</span></code>, <code class="docutils literal notranslate"><span class="pre">correct</span></code> or <code class="docutils literal notranslate"><span class="pre">suggest</span></code> query type, unhandled
parameters are passed through <a class="reference internal" href="../commands/suggest.html"><span class="doc">suggest</span></a>. It
means that you can use parameters of
<a class="reference internal" href="../commands/suggest.html"><span class="doc">suggest</span></a>.</p>
<div class="section" id="groonga-suggest-httpd-required-parameters">
<span id="id1"></span><h3><span class="section-number">7.1.8.5.1. </span>Required parameters<a class="headerlink" href="#groonga-suggest-httpd-required-parameters" title="Permalink to this headline">¶</a></h3>
<p>You must specify the following parameters.</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 33%" />
<col style="width: 33%" />
<col style="width: 33%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>Key</p></th>
<th class="head"><p>Description</p></th>
<th class="head"><p>Note</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">q</span></code></p></td>
<td><p>Input by user. It must be UTF-8 encoded string.</p></td>
<td></td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="required-parameters-for-learning">
<span id="groonga-suggest-httpd-required-parameters-learning"></span><h3><span class="section-number">7.1.8.5.2. </span>Required parameters for learning<a class="headerlink" href="#required-parameters-for-learning" title="Permalink to this headline">¶</a></h3>
<p>You must specify the following parameters when you specify
<a class="reference internal" href="#cmdoption-groonga-suggest-httpd-s"><code class="xref std std-option docutils literal notranslate"><span class="pre">--send-endpoint</span></code></a>.</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 33%" />
<col style="width: 33%" />
<col style="width: 33%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>Key</p></th>
<th class="head"><p>Description</p></th>
<th class="head"><p>Note</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">s</span></code></p></td>
<td><p>Elapsed time since <code class="docutils literal notranslate"><span class="pre">1970-01-01T00:00:00Z</span></code>.</p></td>
<td><p>The unit is millisecond.</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">i</span></code></p></td>
<td><p>Unique ID to distinct each user</p></td>
<td><p>Session ID, IP address and so on will be usable
for this value.</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">l</span></code></p></td>
<td><p>One or more learn target dataset names. You need to use <code class="docutils literal notranslate"><span class="pre">|</span></code>
as separator such as <code class="docutils literal notranslate"><span class="pre">dataset1|dataset2|dataset3</span></code>.</p></td>
<td><p>Dataset name is the name that you specify to
<a class="reference internal" href="groonga-suggest-create-dataset.html"><span class="doc">groonga-suggest-create-dataset</span></a>.</p></td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="required-parameters-for-suggestion">
<span id="groonga-suggest-httpd-required-parameters-suggestion"></span><h3><span class="section-number">7.1.8.5.3. </span>Required parameters for suggestion<a class="headerlink" href="#required-parameters-for-suggestion" title="Permalink to this headline">¶</a></h3>
<p>You must specify the following parameters when you specify one of
<code class="docutils literal notranslate"><span class="pre">complete</span></code>, <code class="docutils literal notranslate"><span class="pre">correct</span></code> and <code class="docutils literal notranslate"><span class="pre">suggest</span></code> to <code class="docutils literal notranslate"><span class="pre">t</span></code> parameter.</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 33%" />
<col style="width: 33%" />
<col style="width: 33%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>Key</p></th>
<th class="head"><p>Description</p></th>
<th class="head"><p>Note</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">n</span></code></p></td>
<td><p>The dataset name to use computing suggestion result.</p></td>
<td><p>Dataset name is the name that you specify to
<a class="reference internal" href="groonga-suggest-create-dataset.html"><span class="doc">groonga-suggest-create-dataset</span></a>.</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">t</span></code></p></td>
<td><p>The query type.</p>
<p>Available values are <code class="docutils literal notranslate"><span class="pre">complete</span></code>, <code class="docutils literal notranslate"><span class="pre">correct</span></code>, <code class="docutils literal notranslate"><span class="pre">suggest</span></code>.</p>
</td>
<td><p>You can specify multiple types. You need to use <code class="docutils literal notranslate"><span class="pre">|</span></code> as
separator such as <code class="docutils literal notranslate"><span class="pre">complete|correct</span></code>.</p></td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="groonga-suggest-httpd-optional-parameters">
<span id="id2"></span><h3><span class="section-number">7.1.8.5.4. </span>Optional parameters<a class="headerlink" href="#groonga-suggest-httpd-optional-parameters" title="Permalink to this headline">¶</a></h3>
<p>Here are optional parameters.</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 33%" />
<col style="width: 33%" />
<col style="width: 33%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>Key</p></th>
<th class="head"><p>Description</p></th>
<th class="head"><p>Note</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">callback</span></code></p></td>
<td><p>Function name for JSONP</p></td>
<td></td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="optional-parameters-for-learning">
<span id="groonga-suggest-httpd-optional-parameters-learning"></span><h3><span class="section-number">7.1.8.5.5. </span>Optional parameters for learning<a class="headerlink" href="#optional-parameters-for-learning" title="Permalink to this headline">¶</a></h3>
<p>Here are optional parameters when you specify
<a class="reference internal" href="#cmdoption-groonga-suggest-httpd-s"><code class="xref std std-option docutils literal notranslate"><span class="pre">--send-endpoint</span></code></a>.</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 33%" />
<col style="width: 33%" />
<col style="width: 33%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>Key</p></th>
<th class="head"><p>Description</p></th>
<th class="head"><p>Note</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">t</span></code></p></td>
<td><p>The query type.</p>
<p>Available value is only <code class="docutils literal notranslate"><span class="pre">submit</span></code>.</p>
</td>
<td><p>You must specify <code class="docutils literal notranslate"><span class="pre">submit</span></code> when user submits the input
specified as <code class="docutils literal notranslate"><span class="pre">q</span></code>.</p>
<p>You must not specify <code class="docutils literal notranslate"><span class="pre">submit</span></code> for user inputs that aren’t
submitted yet. You can use suggestion by specifying
<code class="docutils literal notranslate"><span class="pre">complete</span></code>, <code class="docutils literal notranslate"><span class="pre">correct</span></code> and/or <code class="docutils literal notranslate"><span class="pre">suggest</span></code> to <code class="docutils literal notranslate"><span class="pre">t</span></code> when you
doesn’t specify <code class="docutils literal notranslate"><span class="pre">submit</span></code>. See
<a class="reference internal" href="#groonga-suggest-httpd-required-parameters-suggestion"><span class="std std-ref">Required parameters for suggestion</span></a> for
details about these values.</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="section" id="return-value">
<h2><span class="section-number">7.1.8.6. </span>Return value<a class="headerlink" href="#return-value" title="Permalink to this headline">¶</a></h2>
<p><code class="docutils literal notranslate"><span class="pre">groonga-suggest-httpd</span></code> returns the following format response. It’s
the same format as body of <a class="reference internal" href="../commands/suggest.html"><span class="doc">suggest</span></a>:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>{
  TYPE1: [
    [CANDIDATE_1, SCORE_1],
    [CANDIDATE_2, SCORE_2],
    ...,
    [CANDIDATE_N, SCORE_N]
  ],
  TYPE2: [
    [CANDIDATE_1, SCORE_1],
    [CANDIDATE_2, SCORE_2],
    ...,
    [CANDIDATE_N, SCORE_N]
  ],
  ...
}
</pre></div>
</div>
<p>Here is the response when <code class="docutils literal notranslate"><span class="pre">t</span></code> is <code class="docutils literal notranslate"><span class="pre">submit</span></code>:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>{}
</pre></div>
</div>
<div class="section" id="type">
<h3><span class="section-number">7.1.8.6.1. </span><code class="docutils literal notranslate"><span class="pre">TYPE</span></code><a class="headerlink" href="#type" title="Permalink to this headline">¶</a></h3>
<p>One of <code class="docutils literal notranslate"><span class="pre">complete</span></code>, <code class="docutils literal notranslate"><span class="pre">correct</span></code> and <code class="docutils literal notranslate"><span class="pre">suggest</span></code>.</p>
</div>
<div class="section" id="candidate-n">
<h3><span class="section-number">7.1.8.6.2. </span><code class="docutils literal notranslate"><span class="pre">CANDIDATE_N</span></code><a class="headerlink" href="#candidate-n" title="Permalink to this headline">¶</a></h3>
<p>The string of candidate in UTF-8.</p>
</div>
<div class="section" id="score-n">
<h3><span class="section-number">7.1.8.6.3. </span><code class="docutils literal notranslate"><span class="pre">SCORE_N</span></code><a class="headerlink" href="#score-n" title="Permalink to this headline">¶</a></h3>
<p>The score of the candidate.</p>
<p>Candidates are sorted by score descendant.</p>
</div>
</div>
<div class="section" id="see-also">
<h2><span class="section-number">7.1.8.7. </span>See also<a class="headerlink" href="#see-also" title="Permalink to this headline">¶</a></h2>
<blockquote>
<div><ul class="simple">
<li><p><a class="reference internal" href="../commands/suggest.html"><span class="doc">suggest</span></a></p></li>
</ul>
</div></blockquote>
</div>
</div>


            <div class="clearer"></div>
          </div>
        </div>
      </div>
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
  <h3><a href="../../index.html">Table of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">7.1.8. <code class="docutils literal notranslate"><span class="pre">groonga-suggest-httpd</span></code></a><ul>
<li><a class="reference internal" href="#summary">7.1.8.1. Summary</a></li>
<li><a class="reference internal" href="#syntax">7.1.8.2. Syntax</a></li>
<li><a class="reference internal" href="#usage">7.1.8.3. Usage</a><ul>
<li><a class="reference internal" href="#setup">7.1.8.3.1. Setup</a></li>
<li><a class="reference internal" href="#launch-groonga-suggest-learner">7.1.8.3.2. Launch <code class="docutils literal notranslate"><span class="pre">groonga-suggest-learner</span></code></a></li>
<li><a class="reference internal" href="#launch-groonga-suggest-httpd">7.1.8.3.3. Launch <code class="docutils literal notranslate"><span class="pre">groonga-suggest-httpd</span></code></a></li>
<li><a class="reference internal" href="#learn-from-user-inputs">7.1.8.3.4. Learn from user inputs</a></li>
<li><a class="reference internal" href="#use-suggested-response">7.1.8.3.5. Use suggested response</a></li>
</ul>
</li>
<li><a class="reference internal" href="#command-line-parameters">7.1.8.4. Command line parameters</a><ul>
<li><a class="reference internal" href="#required-parameters">7.1.8.4.1. Required parameters</a><ul>
<li><a class="reference internal" href="#database-path">7.1.8.4.1.1. <code class="docutils literal notranslate"><span class="pre">DATABASE_PATH</span></code></a></li>
</ul>
</li>
<li><a class="reference internal" href="#optional-parameters">7.1.8.4.2. Optional parameters</a></li>
</ul>
</li>
<li><a class="reference internal" href="#get-parameters">7.1.8.5. GET parameters</a><ul>
<li><a class="reference internal" href="#groonga-suggest-httpd-required-parameters">7.1.8.5.1. Required parameters</a></li>
<li><a class="reference internal" href="#required-parameters-for-learning">7.1.8.5.2. Required parameters for learning</a></li>
<li><a class="reference internal" href="#required-parameters-for-suggestion">7.1.8.5.3. Required parameters for suggestion</a></li>
<li><a class="reference internal" href="#groonga-suggest-httpd-optional-parameters">7.1.8.5.4. Optional parameters</a></li>
<li><a class="reference internal" href="#optional-parameters-for-learning">7.1.8.5.5. Optional parameters for learning</a></li>
</ul>
</li>
<li><a class="reference internal" href="#return-value">7.1.8.6. Return value</a><ul>
<li><a class="reference internal" href="#type">7.1.8.6.1. <code class="docutils literal notranslate"><span class="pre">TYPE</span></code></a></li>
<li><a class="reference internal" href="#candidate-n">7.1.8.6.2. <code class="docutils literal notranslate"><span class="pre">CANDIDATE_N</span></code></a></li>
<li><a class="reference internal" href="#score-n">7.1.8.6.3. <code class="docutils literal notranslate"><span class="pre">SCORE_N</span></code></a></li>
</ul>
</li>
<li><a class="reference internal" href="#see-also">7.1.8.7. See also</a></li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="groonga-suggest-create-dataset.html"
                        title="previous chapter"><span class="section-number">7.1.7. </span>groonga-suggest-create-dataset</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="groonga-suggest-learner.html"
                        title="next chapter"><span class="section-number">7.1.9. </span>groonga-suggest-learner</a></p>
<div id="searchbox" style="display: none" role="search">
  <h3 id="searchlabel">Quick search</h3>
    <div class="searchformwrapper">
    <form class="search" action="../../search.html" method="get">
      <input type="text" name="q" aria-labelledby="searchlabel" />
      <input type="submit" value="Go" />
    </form>
    </div>
</div>
<script>$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="groonga-suggest-learner.html" title="7.1.9. groonga-suggest-learner"
             >next</a> |</li>
        <li class="right" >
          <a href="groonga-suggest-create-dataset.html" title="7.1.7. groonga-suggest-create-dataset"
             >previous</a> |</li>
        <li class="nav-item nav-item-0"><a href="../../index.html">Groonga v10.1.1-31-g1e46ba6 documentation</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="../../reference.html" ><span class="section-number">7. </span>Reference manual</a> &#187;</li>
          <li class="nav-item nav-item-2"><a href="../executables.html" ><span class="section-number">7.1. </span>Executables</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href=""><span class="section-number">7.1.8. </span><code class="docutils literal notranslate"><span class="pre">groonga-suggest-httpd</span></code></a></li> 
      </ul>
    </div>
    <div class="footer" role="contentinfo">
        &#169; Copyright 2009-2021, Brazil, Inc.
    </div>
  </body>
</html>