File: logical_count.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 (869 lines) | stat: -rw-r--r-- 58,193 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
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869


<!DOCTYPE html>

<html lang="en">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>7.3.32. logical_count &#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.3.33. logical_parameters" href="logical_parameters.html" />
    <link rel="prev" title="7.3.31. log_reopen" href="log_reopen.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/commands/logical_count.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="logical_parameters.html" title="7.3.33. logical_parameters"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="log_reopen.html" title="7.3.31. log_reopen"
             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="../command.html" accesskey="U"><span class="section-number">7.3. </span>Command</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href=""><span class="section-number">7.3.32. </span><code class="docutils literal notranslate"><span class="pre">logical_count</span></code></a></li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body" role="main">
            
  <div class="section" id="logical-count">
<h1><span class="section-number">7.3.32. </span><code class="docutils literal notranslate"><span class="pre">logical_count</span></code><a class="headerlink" href="#logical-count" title="Permalink to this headline">¶</a></h1>
<div class="section" id="summary">
<h2><span class="section-number">7.3.32.1. </span>Summary<a class="headerlink" href="#summary" title="Permalink to this headline">¶</a></h2>
<div class="versionadded">
<p><span class="versionmodified added">New in version 5.0.0.</span></p>
</div>
<p><code class="docutils literal notranslate"><span class="pre">logical_count</span></code> is a command that has only count feature in
<a class="reference internal" href="logical_select.html"><span class="doc">logical_select</span></a>. <a class="reference internal" href="logical_select.html"><span class="doc">logical_select</span></a> searches records from
multiple tables, outputs the number of matched records, outputs
columns of the matched records and so on. <code class="docutils literal notranslate"><span class="pre">logical_count</span></code> only
searches records from multiple tables and output the number of matched
records.</p>
<p><code class="docutils literal notranslate"><span class="pre">logical_count</span></code> is useful when you just want the number of matched
records. You can use <code class="docutils literal notranslate"><span class="pre">logical_count</span></code> and <a class="reference internal" href="logical_range_filter.html"><span class="doc">logical_range_filter</span></a>
at once. You can show the first N matched records before you get the
number of matched records. If you use only <a class="reference internal" href="logical_select.html"><span class="doc">logical_select</span></a>, you
need to wait finishing all search.</p>
<p>You need to <a class="reference internal" href="plugin_register.html"><span class="doc">plugin_register</span></a> <code class="docutils literal notranslate"><span class="pre">sharding</span></code> plugin because
this command is included in <code class="docutils literal notranslate"><span class="pre">sharding</span></code> plugin.</p>
</div>
<div class="section" id="syntax">
<h2><span class="section-number">7.3.32.2. </span>Syntax<a class="headerlink" href="#syntax" title="Permalink to this headline">¶</a></h2>
<p>This command takes many parameters.</p>
<p>The required parameters are <code class="docutils literal notranslate"><span class="pre">logical_table</span></code> and <code class="docutils literal notranslate"><span class="pre">shard_key</span></code>. Other
parameters are optional:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>logical_count
  logical_table
  shard_key
  [min=null]
  [min_border=&quot;include&quot;]
  [max=null]
  [max_border=&quot;include&quot;]
  [filter=null]
  [post_filter=null]
</pre></div>
</div>
<p>There are some parameters that can be only used as named
parameters. You can’t use these parameters as ordered parameters. You
must specify parameter name.</p>
<p>Here are parameters that can be only used as named parameters:</p>
<blockquote>
<div><ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">cache=no</span></code></p></li>
</ul>
</div></blockquote>
<div class="versionadded">
<p><span class="versionmodified added">New in version 7.0.9: </span>This command has the following named parameters for dynamic columns:</p>
<blockquote>
<div><ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">columns[${NAME}].stage=null</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">columns[${NAME}].flags=COLUMN_SCALAR</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">columns[${NAME}].type=null</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">columns[${NAME}].value=null</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">columns[${NAME}].window.sort_keys=null</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">columns[${NAME}].window.group_keys=null</span></code></p></li>
</ul>
</div></blockquote>
<p>You can use one or more alphabets, digits, <code class="docutils literal notranslate"><span class="pre">_</span></code> for <code class="docutils literal notranslate"><span class="pre">${NAME}</span></code>. For
example, <code class="docutils literal notranslate"><span class="pre">column1</span></code> is a valid <code class="docutils literal notranslate"><span class="pre">${NAME}</span></code>. This is the same rule as
normal column. See also <a class="reference internal" href="column_create.html#column-create-name"><span class="std std-ref">name</span></a>.</p>
<p>Parameters that have the same <code class="docutils literal notranslate"><span class="pre">${NAME}</span></code> are grouped.</p>
<p>For example, the following parameters specify one dynamic column:</p>
<blockquote>
<div><ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">--columns[name].stage</span> <span class="pre">initial</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">--columns[name].type</span> <span class="pre">UInt32</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">--columns[name].value</span> <span class="pre">29</span></code></p></li>
</ul>
</div></blockquote>
<p>The following parameters specify two dynamic columns:</p>
<blockquote>
<div><ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">--columns[name1].stage</span> <span class="pre">initial</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">--columns[name1].type</span> <span class="pre">UInt32</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">--columns[name1].value</span> <span class="pre">29</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">--columns[name2].stage</span> <span class="pre">initial</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">--columns[name2].type</span> <span class="pre">Float</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">--columns[name2].value</span> <span class="pre">'_score</span> <span class="pre">*</span> <span class="pre">0.1'</span></code></p></li>
</ul>
</div></blockquote>
</div>
</div>
<div class="section" id="usage">
<span id="logical-count-usage"></span><h2><span class="section-number">7.3.32.3. </span>Usage<a class="headerlink" href="#usage" title="Permalink to this headline">¶</a></h2>
<p>Let’s learn about usage with examples. This section shows many popular
usages.</p>
<p>You need to register <code class="docutils literal notranslate"><span class="pre">sharding</span></code> plugin because this command is
included in <code class="docutils literal notranslate"><span class="pre">sharding</span></code> plugin.</p>
<p>Execution example:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>plugin_register sharding
# [[0, 1337566253.89858, 0.000355720520019531], true]
</pre></div>
</div>
<p>Note that <code class="docutils literal notranslate"><span class="pre">logical_count</span></code> is implemented as an experimental plugin, and the specification may be changed in the future.</p>
<p>Here is the simple example which shows how to use this feature. Let’s consider to count specified logs which are stored into multiple tables.</p>
<p>Here are a schema definition and sample data to show usage.</p>
<p>Execution example:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>table_create Entries_20150708 TABLE_HASH_KEY ShortText
# [[0, 1337566253.89858, 0.000355720520019531], true]
column_create Entries_20150708 created_at COLUMN_SCALAR Time
# [[0, 1337566253.89858, 0.000355720520019531], true]
column_create Entries_20150708 content COLUMN_SCALAR Text
# [[0, 1337566253.89858, 0.000355720520019531], true]
column_create Entries_20150708 n_likes COLUMN_SCALAR UInt32
# [[0, 1337566253.89858, 0.000355720520019531], true]
column_create Entries_20150708 tag COLUMN_SCALAR ShortText
# [[0, 1337566253.89858, 0.000355720520019531], true]
table_create Entries_20150709 TABLE_HASH_KEY ShortText
# [[0, 1337566253.89858, 0.000355720520019531], true]
column_create Entries_20150709 created_at COLUMN_SCALAR Time
# [[0, 1337566253.89858, 0.000355720520019531], true]
column_create Entries_20150709 content COLUMN_SCALAR Text
# [[0, 1337566253.89858, 0.000355720520019531], true]
column_create Entries_20150709 n_likes COLUMN_SCALAR UInt32
# [[0, 1337566253.89858, 0.000355720520019531], true]
column_create Entries_20150709 tag COLUMN_SCALAR ShortText
# [[0, 1337566253.89858, 0.000355720520019531], true]
table_create Terms TABLE_PAT_KEY ShortText \
  --default_tokenizer TokenBigram \
  --normalizer NormalizerAuto
# [[0, 1337566253.89858, 0.000355720520019531], true]
column_create Terms entries_key_index_20150708 \
  COLUMN_INDEX|WITH_POSITION Entries_20150708 _key
# [[0, 1337566253.89858, 0.000355720520019531], true]
column_create Terms entries_content_index_20150708 \
  COLUMN_INDEX|WITH_POSITION Entries_20150708 content
# [[0, 1337566253.89858, 0.000355720520019531], true]
column_create Terms entries_key_index_20150709 \
  COLUMN_INDEX|WITH_POSITION Entries_20150709 _key
# [[0, 1337566253.89858, 0.000355720520019531], true]
column_create Terms entries_content_index_20150709 \
  COLUMN_INDEX|WITH_POSITION Entries_20150709 content
# [[0, 1337566253.89858, 0.000355720520019531], true]
load --table Entries_20150708
[
{&quot;_key&quot;:       &quot;The first post!&quot;,
 &quot;created_at&quot;: &quot;2015/07/08 00:00:00&quot;,
 &quot;content&quot;:    &quot;Welcome! This is my first post!&quot;,
 &quot;n_likes&quot;:    5,
 &quot;tag&quot;:        &quot;Hello&quot;},
{&quot;_key&quot;:       &quot;Groonga&quot;,
 &quot;created_at&quot;: &quot;2015/07/08 01:00:00&quot;,
 &quot;content&quot;:    &quot;I started to use Groonga. It&#39;s very fast!&quot;,
 &quot;n_likes&quot;:    10,
 &quot;tag&quot;:        &quot;Groonga&quot;},
{&quot;_key&quot;:       &quot;Mroonga&quot;,
 &quot;created_at&quot;: &quot;2015/07/08 02:00:00&quot;,
 &quot;content&quot;:    &quot;I also started to use Mroonga. It&#39;s also very fast! Really fast!&quot;,
 &quot;n_likes&quot;:    15,
 &quot;tag&quot;:        &quot;Groonga&quot;}
]
# [[0, 1337566253.89858, 0.000355720520019531], 3]
load --table Entries_20150709
[
{&quot;_key&quot;:       &quot;Good-bye Senna&quot;,
 &quot;created_at&quot;: &quot;2015/07/09 00:00:00&quot;,
 &quot;content&quot;:    &quot;I migrated all Senna system!&quot;,
 &quot;n_likes&quot;:    3,
 &quot;tag&quot;:        &quot;Senna&quot;},
{&quot;_key&quot;:       &quot;Good-bye Tritonn&quot;,
 &quot;created_at&quot;: &quot;2015/07/09 01:00:00&quot;,
 &quot;content&quot;:    &quot;I also migrated all Tritonn system!&quot;,
 &quot;n_likes&quot;:    3,
 &quot;tag&quot;:        &quot;Senna&quot;}
]
# [[0, 1337566253.89858, 0.000355720520019531], 2]
</pre></div>
</div>
<p>There are two tables, <code class="docutils literal notranslate"><span class="pre">Entries_20150708</span></code> and <code class="docutils literal notranslate"><span class="pre">Entries_20150709</span></code>,
for blog entries.</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>You need to use <code class="docutils literal notranslate"><span class="pre">${LOGICAL_TABLE_NAME}_${YYYYMMDD}</span></code> naming rule
for table names. In this example, <code class="docutils literal notranslate"><span class="pre">LOGICAL_TABLE_NAME</span></code> is
<code class="docutils literal notranslate"><span class="pre">Entries</span></code> and <code class="docutils literal notranslate"><span class="pre">YYYYMMDD</span></code> is <code class="docutils literal notranslate"><span class="pre">20150708</span></code> or <code class="docutils literal notranslate"><span class="pre">20150709</span></code>.</p>
</div>
<p>An entry has title, created time, content, the number of likes for the
entry and tag. Title is key of <code class="docutils literal notranslate"><span class="pre">Entries_YYYYMMDD</span></code>. Created time is
value of <code class="docutils literal notranslate"><span class="pre">Entries_YYYYMMDD.created_at</span></code> column. Content is value of
<code class="docutils literal notranslate"><span class="pre">Entries_YYYYMMDD.content</span></code> column. The number of likes is value of
<code class="docutils literal notranslate"><span class="pre">Entries_YYYYMMDD.n_likes</span></code> column. Tag is value of
<code class="docutils literal notranslate"><span class="pre">Entries_YYYYMMDD.tag</span></code> column.</p>
<p><code class="docutils literal notranslate"><span class="pre">Entries_YYYYMMDD._key</span></code> column and <code class="docutils literal notranslate"><span class="pre">Entries_YYYYMMDD.content</span></code>
column are indexed using <code class="docutils literal notranslate"><span class="pre">TokenBigram</span></code> tokenizer. So both
<code class="docutils literal notranslate"><span class="pre">Entries_YYYYMMDD._key</span></code> and <code class="docutils literal notranslate"><span class="pre">Entries_YYYYMMDD.content</span></code> are
fulltext search ready.</p>
<p>OK. The schema and data for examples are ready.</p>
<p>Here is an example to count the number of records which have
<code class="docutils literal notranslate"><span class="pre">Groonga</span></code> or <code class="docutils literal notranslate"><span class="pre">Senna</span></code> in <code class="docutils literal notranslate"><span class="pre">content</span></code> column. <code class="docutils literal notranslate"><span class="pre">logical_count</span></code>
searches records over all <code class="docutils literal notranslate"><span class="pre">Entries_YYYYMMDD</span></code> tables.</p>
<p>Execution example:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>logical_count \
  --logical_table Entries \
  --shard_key created_at \
  --filter &#39;query(&quot;content&quot;, &quot;Groonga OR Senna&quot;)&#39;
# [[0, 1337566253.89858, 0.000355720520019531], 2]
</pre></div>
</div>
<p>Here are matched records:</p>
<blockquote>
<div><ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">_key:&quot;Groonga&quot;</span></code> in <code class="docutils literal notranslate"><span class="pre">Entries_20150708</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">_key:&quot;Good-bye</span> <span class="pre">Senna&quot;</span></code> in <code class="docutils literal notranslate"><span class="pre">Entries_20150709</span></code></p></li>
</ul>
</div></blockquote>
</div>
<div class="section" id="parameters">
<h2><span class="section-number">7.3.32.4. </span>Parameters<a class="headerlink" href="#parameters" title="Permalink to this headline">¶</a></h2>
<p>This section describes parameters of this command.</p>
<div class="section" id="required-parameters">
<h3><span class="section-number">7.3.32.4.1. </span>Required parameters<a class="headerlink" href="#required-parameters" title="Permalink to this headline">¶</a></h3>
<p>There are required parameters, <code class="docutils literal notranslate"><span class="pre">logical_table</span></code> and <code class="docutils literal notranslate"><span class="pre">shard_key</span></code>.</p>
<div class="section" id="logical-table">
<span id="logical-count-logical-table"></span><h4><span class="section-number">7.3.32.4.1.1. </span><code class="docutils literal notranslate"><span class="pre">logical_table</span></code><a class="headerlink" href="#logical-table" title="Permalink to this headline">¶</a></h4>
<p>Specifies logical table name. It means table name without
<code class="docutils literal notranslate"><span class="pre">_YYYYMMDD</span></code> postfix.  If you use actual table such as
<code class="docutils literal notranslate"><span class="pre">Logs_20150203</span></code>, <code class="docutils literal notranslate"><span class="pre">Logs_20150203</span></code> and so on, logical table name is
<code class="docutils literal notranslate"><span class="pre">Logs</span></code>.</p>
<p>You can count all records by specifying only <code class="docutils literal notranslate"><span class="pre">logical_table</span></code> and
<code class="docutils literal notranslate"><span class="pre">shard_key</span></code> parameters. They are required parameters.</p>
<p>Execution example:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>logical_count \
  --logical_table Entries \
  --shard_key created_at
# [[0, 1337566253.89858, 0.000355720520019531], 5]
</pre></div>
</div>
<p>If nonexistent table is specified, an error is returned.</p>
<p>Execution example:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>logical_count \
  --logical_table Nonexistent \
  --shard_key created_at
# [
#   [
#     -22,
#     1337566253.89858,
#     0.000355720520019531,
#     &quot;[logical_count] no shard exists: logical_table: &lt;Nonexistent&gt;: shard_key: &lt;created_at&gt;&quot;,
#     [
#       [
#         &quot;Groonga::Sharding::LogicalCountCommand.run_body&quot;,
#         &quot;/home/horimoto/work/release/groonga/groonga.clean/plugins/sharding/logical_count.rb&quot;,
#         30
#       ]
#     ]
#   ]
# ]
</pre></div>
</div>
</div>
<div class="section" id="shard-key">
<span id="logical-count-shard-key"></span><h4><span class="section-number">7.3.32.4.1.2. </span><code class="docutils literal notranslate"><span class="pre">shard_key</span></code><a class="headerlink" href="#shard-key" title="Permalink to this headline">¶</a></h4>
<p>Specifies column name which is treated as shared key. Shard key is a
column that stores data that is used for distributing records to
suitable shards.</p>
<p>Shard key must be <code class="docutils literal notranslate"><span class="pre">Time</span></code> type for now.</p>
<p>See <a class="reference internal" href="#logical-count-logical-table"><span class="std std-ref">logical_table</span></a> how to specify <code class="docutils literal notranslate"><span class="pre">shard_key</span></code>.</p>
</div>
</div>
<div class="section" id="optional-parameters">
<h3><span class="section-number">7.3.32.4.2. </span>Optional parameters<a class="headerlink" href="#optional-parameters" title="Permalink to this headline">¶</a></h3>
<p>There are optional parameters.</p>
<div class="section" id="min">
<span id="logical-count-min"></span><h4><span class="section-number">7.3.32.4.2.1. </span><code class="docutils literal notranslate"><span class="pre">min</span></code><a class="headerlink" href="#min" title="Permalink to this headline">¶</a></h4>
<p>Specifies the minimum value of <code class="docutils literal notranslate"><span class="pre">shard_key</span></code> column. If shard doesn’t
have any matched records, the shard isn’t searched.</p>
<p>For example, <code class="docutils literal notranslate"><span class="pre">min</span></code> is <code class="docutils literal notranslate"><span class="pre">&quot;2015/07/09</span> <span class="pre">00:00:00&quot;</span></code>, <code class="docutils literal notranslate"><span class="pre">Entry_20150708</span></code>
isn’t searched. Because <code class="docutils literal notranslate"><span class="pre">Entry_20150708</span></code> has only records for
<code class="docutils literal notranslate"><span class="pre">&quot;2015/07/08&quot;</span></code>.</p>
<p>The following example only uses <code class="docutils literal notranslate"><span class="pre">Entry_20150709</span></code>
table. <code class="docutils literal notranslate"><span class="pre">Entry_20150708</span></code> isn’t used.</p>
<p>Execution example:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>logical_count \
  --logical_table Entries \
  --shard_key created_at \
  --min &quot;2015/07/09 00:00:00&quot;
# [[0, 1337566253.89858, 0.000355720520019531], 2]
</pre></div>
</div>
</div>
<div class="section" id="min-border">
<span id="logical-count-min-border"></span><h4><span class="section-number">7.3.32.4.2.2. </span><code class="docutils literal notranslate"><span class="pre">min_border</span></code><a class="headerlink" href="#min-border" title="Permalink to this headline">¶</a></h4>
<p>Specifies whether the minimum value is included or not. Here is
available values.</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 50%" />
<col style="width: 50%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>Value</p></th>
<th class="head"><p>Description</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">include</span></code></p></td>
<td><p>Includes <code class="docutils literal notranslate"><span class="pre">min</span></code> value. This is the default.</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">exclude</span></code></p></td>
<td><p>Doesn’t include <code class="docutils literal notranslate"><span class="pre">min</span></code> value.</p></td>
</tr>
</tbody>
</table>
<p>Here is an example for <code class="docutils literal notranslate"><span class="pre">exclude</span></code>. The result doesn’t include the
<code class="docutils literal notranslate"><span class="pre">&quot;Good-bye</span> <span class="pre">Senna&quot;</span></code> record because its <code class="docutils literal notranslate"><span class="pre">created_at</span></code> value is
<code class="docutils literal notranslate"><span class="pre">&quot;2015/07/09</span> <span class="pre">00:00:00&quot;</span></code>.</p>
<p>Execution example:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>logical_count \
  --logical_table Entries \
  --shard_key created_at \
  --min &quot;2015/07/09 00:00:00&quot; \
  --min_border &quot;exclude&quot;
# [[0, 1337566253.89858, 0.000355720520019531], 1]
</pre></div>
</div>
</div>
<div class="section" id="max">
<span id="logical-count-max"></span><h4><span class="section-number">7.3.32.4.2.3. </span><code class="docutils literal notranslate"><span class="pre">max</span></code><a class="headerlink" href="#max" title="Permalink to this headline">¶</a></h4>
<p>Specifies the maximum value of <code class="docutils literal notranslate"><span class="pre">shard_key</span></code> column. If shard doesn’t
have any matched records, the shard isn’t searched.</p>
<p>For example, <code class="docutils literal notranslate"><span class="pre">max</span></code> is <code class="docutils literal notranslate"><span class="pre">&quot;2015/07/08</span> <span class="pre">23:59:59&quot;</span></code>, <code class="docutils literal notranslate"><span class="pre">Entry_20150709</span></code>
isn’t searched. Because <code class="docutils literal notranslate"><span class="pre">Entry_20150709</span></code> has only records for
<code class="docutils literal notranslate"><span class="pre">&quot;&quot;2015/07/09&quot;</span></code>.</p>
<p>The following example only uses <code class="docutils literal notranslate"><span class="pre">Entry_20150708</span></code>
table. <code class="docutils literal notranslate"><span class="pre">Entry_20150709</span></code> isn’t used.</p>
<p>Execution example:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>logical_count \
  --logical_table Entries \
  --shard_key created_at \
  --max &quot;2015/07/08 23:59:59&quot;
# [[0, 1337566253.89858, 0.000355720520019531], 3]
</pre></div>
</div>
</div>
<div class="section" id="max-border">
<span id="logical-count-max-border"></span><h4><span class="section-number">7.3.32.4.2.4. </span><code class="docutils literal notranslate"><span class="pre">max_border</span></code><a class="headerlink" href="#max-border" title="Permalink to this headline">¶</a></h4>
<p>Specifies whether the maximum value is included or not. Here is
available values.</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 50%" />
<col style="width: 50%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>Value</p></th>
<th class="head"><p>Description</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">include</span></code></p></td>
<td><p>Includes <code class="docutils literal notranslate"><span class="pre">max</span></code> value. This is the default.</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">exclude</span></code></p></td>
<td><p>Doesn’t include <code class="docutils literal notranslate"><span class="pre">max</span></code> value.</p></td>
</tr>
</tbody>
</table>
<p>Here is an example for <code class="docutils literal notranslate"><span class="pre">exclude</span></code>. The result doesn’t include the
<code class="docutils literal notranslate"><span class="pre">&quot;Good-bye</span> <span class="pre">Senna&quot;</span></code> record because its <code class="docutils literal notranslate"><span class="pre">created_at</span></code> value is
<code class="docutils literal notranslate"><span class="pre">&quot;2015/07/09</span> <span class="pre">00:00:00&quot;</span></code>.</p>
<p>Execution example:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>logical_count \
  --logical_table Entries \
  --shard_key created_at \
  --max &quot;2015/07/09 00:00:00&quot; \
  --max_border &quot;exclude&quot;
# [[0, 1337566253.89858, 0.000355720520019531], 3]
</pre></div>
</div>
</div>
</div>
<div class="section" id="search-related-parameters">
<span id="logical-count-search-related-parameters"></span><h3><span class="section-number">7.3.32.4.3. </span>Search related parameters<a class="headerlink" href="#search-related-parameters" title="Permalink to this headline">¶</a></h3>
<p>This command provides <a class="reference internal" href="select.html"><span class="doc">select</span></a> compatible search related
parameters.</p>
<div class="section" id="filter">
<span id="logical-count-filter"></span><h4><span class="section-number">7.3.32.4.3.1. </span><code class="docutils literal notranslate"><span class="pre">filter</span></code><a class="headerlink" href="#filter" title="Permalink to this headline">¶</a></h4>
<p>Corresponds to <a class="reference internal" href="select.html#select-filter"><span class="std std-ref">filter</span></a> in <a class="reference internal" href="select.html"><span class="doc">select</span></a>. See
<a class="reference internal" href="select.html#select-filter"><span class="std std-ref">filter</span></a> for details.</p>
<p>Here is an example:</p>
<p>Execution example:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>logical_count \
  --logical_table Entries \
  --shard_key created_at \
  --filter &quot;n_likes &lt;= 5&quot;
# [[0, 1337566253.89858, 0.000355720520019531], 3]
</pre></div>
</div>
</div>
<div class="section" id="post-filter">
<span id="logical-count-post-filter"></span><h4><span class="section-number">7.3.32.4.3.2. </span><code class="docutils literal notranslate"><span class="pre">post_filter</span></code><a class="headerlink" href="#post-filter" title="Permalink to this headline">¶</a></h4>
<div class="versionadded">
<p><span class="versionmodified added">New in version 8.0.1.</span></p>
</div>
<p>Specifies the filter text that is processed after <code class="docutils literal notranslate"><span class="pre">filtered</span></code> stage
dynamic columns are generated. You can use <code class="docutils literal notranslate"><span class="pre">post_filter</span></code> to filter
by <code class="docutils literal notranslate"><span class="pre">filtered</span></code> stage dynamic columns. Others are the same as
<a class="reference internal" href="select.html#select-filter"><span class="std std-ref">filter</span></a>.</p>
<p>Here is an example that shows entries only in popular tag. All target
entries have <code class="docutils literal notranslate"><span class="pre">system</span></code> or <code class="docutils literal notranslate"><span class="pre">use</span></code> words:</p>
<p>Execution example:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>logical_count \
  --logical_table Entries \
  --shard_key created_at \
  --columns[n_likes_sum_per_tag].stage filtered \
  --columns[n_likes_sum_per_tag].type UInt32 \
  --columns[n_likes_sum_per_tag].value &#39;window_sum(n_likes)&#39; \
  --columns[n_likes_sum_per_tag].window.group_keys &#39;tag&#39; \
  --filter &#39;content @ &quot;system&quot; || content @ &quot;use&quot;&#39; \
  --post_filter &#39;n_likes_sum_per_tag &gt; 10&#39; \
  --output_columns _key,n_likes,n_likes_sum_per_tag
# [[0,1519095081.579662,0.4281206130981445],2]
</pre></div>
</div>
</div>
</div>
<div class="section" id="dynamic-column-related-parameters">
<span id="logical-count-dynamic-column-related-parameters"></span><h3><span class="section-number">7.3.32.4.4. </span>Dynamic column related parameters<a class="headerlink" href="#dynamic-column-related-parameters" title="Permalink to this headline">¶</a></h3>
<div class="versionadded">
<p><span class="versionmodified added">New in version 7.0.9.</span></p>
</div>
<p>All dynamic column related parameters in <a class="reference internal" href="select.html"><span class="doc">select</span></a> are
supported. See <a class="reference internal" href="select.html#select-dynamic-column-related-parameters"><span class="std std-ref">Dynamic column related parameters</span></a> for
details.</p>
<div class="section" id="columns-name-stage">
<span id="logical-count-columns-name-stage"></span><h4><span class="section-number">7.3.32.4.4.1. </span><code class="docutils literal notranslate"><span class="pre">columns[${NAME}].stage</span></code><a class="headerlink" href="#columns-name-stage" title="Permalink to this headline">¶</a></h4>
<div class="versionadded">
<p><span class="versionmodified added">New in version 7.0.9.</span></p>
</div>
<p>Corresponds to <a class="reference internal" href="select.html#select-columns-name-stage"><span class="std std-ref">columns[${NAME}].stage</span></a> in <a class="reference internal" href="select.html"><span class="doc">select</span></a>. See
<a class="reference internal" href="select.html#select-columns-name-stage"><span class="std std-ref">columns[${NAME}].stage</span></a> for details.</p>
<p>This is a required parameter.</p>
<p><code class="docutils literal notranslate"><span class="pre">initial</span></code> stage and <code class="docutils literal notranslate"><span class="pre">filtered</span></code> stage are valid. Because there are
no processes after <code class="docutils literal notranslate"><span class="pre">output</span></code> stages.</p>
<div class="versionadded">
<p><span class="versionmodified added">New in version 8.0.1: </span><code class="docutils literal notranslate"><span class="pre">filtered</span></code> stage is valid since 8.0.1.</p>
</div>
<p>Here is an example that creates <code class="docutils literal notranslate"><span class="pre">is_popular</span></code> column at <code class="docutils literal notranslate"><span class="pre">initial</span></code>
stage. You can use <code class="docutils literal notranslate"><span class="pre">is_popular</span></code> in all parameters such as <code class="docutils literal notranslate"><span class="pre">filter</span></code>:</p>
<p>Execution example:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>logical_count \
  --logical_table Entries \
  --shard_key created_at \
  --columns[is_popular].stage initial \
  --columns[is_popular].type Bool \
  --columns[is_popular].value &#39;n_likes &gt;= 10&#39; \
  --filter is_popular
# [[0, 1337566253.89858, 0.000355720520019531], 2]
</pre></div>
</div>
</div>
<div class="section" id="columns-name-flags">
<span id="logical-count-columns-name-flags"></span><h4><span class="section-number">7.3.32.4.4.2. </span><code class="docutils literal notranslate"><span class="pre">columns[${NAME}].flags</span></code><a class="headerlink" href="#columns-name-flags" title="Permalink to this headline">¶</a></h4>
<div class="versionadded">
<p><span class="versionmodified added">New in version 7.0.9.</span></p>
</div>
<p>Corresponds to <a class="reference internal" href="select.html#select-columns-name-flags"><span class="std std-ref">columns[${NAME}].flags</span></a> in <a class="reference internal" href="select.html"><span class="doc">select</span></a>. See
<a class="reference internal" href="select.html#select-columns-name-flags"><span class="std std-ref">columns[${NAME}].flags</span></a> for details.</p>
<p>The default value is <code class="docutils literal notranslate"><span class="pre">COLUMN_SCALAR</span></code>.</p>
<p>Here is an example that creates a vector column by <code class="docutils literal notranslate"><span class="pre">COLUMN_VECTOR</span></code>
flags. <code class="docutils literal notranslate"><span class="pre">plugin_register</span> <span class="pre">functions/vector</span></code> is for using
<a class="reference internal" href="../functions/vector_new.html"><span class="doc">vector_new</span></a> function:</p>
<p>Execution example:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>plugin_register functions/vector
# [[0, 1337566253.89858, 0.000355720520019531], true]
logical_count \
  --logical_table Entries \
  --shard_key created_at \
  --columns[vector].stage initial \
  --columns[vector].flags COLUMN_VECTOR \
  --columns[vector].type UInt32 \
  --columns[vector].value &#39;vector_new(1, 2, 3)&#39; \
  --filter &#39;vector_size(vector) &gt; 2&#39;
# [[0, 1337566253.89858, 0.000355720520019531], 5]
</pre></div>
</div>
</div>
<div class="section" id="columns-name-type">
<span id="logical-count-columns-name-type"></span><h4><span class="section-number">7.3.32.4.4.3. </span><code class="docutils literal notranslate"><span class="pre">columns[${NAME}].type</span></code><a class="headerlink" href="#columns-name-type" title="Permalink to this headline">¶</a></h4>
<div class="versionadded">
<p><span class="versionmodified added">New in version 7.0.9.</span></p>
</div>
<p>Corresponds to <a class="reference internal" href="select.html#select-columns-name-type"><span class="std std-ref">columns[${NAME}].type</span></a> in <a class="reference internal" href="select.html"><span class="doc">select</span></a>. See
<a class="reference internal" href="select.html#select-columns-name-type"><span class="std std-ref">columns[${NAME}].type</span></a> for details.</p>
<p>This is a required parameter.</p>
<p>Here is an example that creates a <code class="docutils literal notranslate"><span class="pre">ShortText</span></code> type column. Stored
value is casted to <code class="docutils literal notranslate"><span class="pre">ShortText</span></code> automatically. In this example,
number is casted to <code class="docutils literal notranslate"><span class="pre">ShortText</span></code>:</p>
<p>Execution example:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>logical_count \
  --logical_table Entries \
  --shard_key created_at \
  --columns[n_likes_string].stage initial \
  --columns[n_likes_string].type ShortText \
  --columns[n_likes_string].value n_likes \
  --filter &#39;n_likes_string == &quot;3&quot;&#39;
# [[0, 1337566253.89858, 0.000355720520019531], 2]
</pre></div>
</div>
</div>
<div class="section" id="columns-name-value">
<span id="logical-count-columns-name-value"></span><h4><span class="section-number">7.3.32.4.4.4. </span><code class="docutils literal notranslate"><span class="pre">columns[${NAME}].value</span></code><a class="headerlink" href="#columns-name-value" title="Permalink to this headline">¶</a></h4>
<div class="versionadded">
<p><span class="versionmodified added">New in version 7.0.9.</span></p>
</div>
<p>Corresponds to <a class="reference internal" href="select.html#select-columns-name-value"><span class="std std-ref">columns[${NAME}].value</span></a> in <a class="reference internal" href="select.html"><span class="doc">select</span></a>. See
<a class="reference internal" href="select.html#select-columns-name-value"><span class="std std-ref">columns[${NAME}].value</span></a> for details.</p>
<p>You need to specify <a class="reference internal" href="../window_function.html"><span class="doc">Window function</span></a> as <code class="docutils literal notranslate"><span class="pre">value</span></code>
value and other window function related parameters when you use window
function. See <a class="reference internal" href="#logical-count-window-function-related-parameters"><span class="std std-ref">Window function related parameters</span></a>
for details.</p>
<p>This is a required parameter.</p>
<p>Here is an example that creates a new dynamic column that stores the
number of characters of content. This example uses
<a class="reference internal" href="../functions/string_length.html"><span class="doc">string_length</span></a> function in
<code class="docutils literal notranslate"><span class="pre">functions/string</span></code> plugin to compute the number of characters in a
string. <a class="reference internal" href="plugin_register.html"><span class="doc">plugin_register</span></a> is used to register
<code class="docutils literal notranslate"><span class="pre">functions/string</span></code> plugin:</p>
<p>Execution example:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>plugin_register functions/string
# [[0, 1337566253.89858, 0.000355720520019531], true]
logical_count \
  --logical_table Entries \
  --shard_key created_at \
  --columns[content_length].stage initial \
  --columns[content_length].type UInt32 \
  --columns[content_length].value &#39;string_length(content)&#39; \
  --filter &#39;content_length &gt;= 40&#39;
# [[0, 1337566253.89858, 0.000355720520019531], 2]
</pre></div>
</div>
</div>
</div>
<div class="section" id="window-function-related-parameters">
<span id="logical-count-window-function-related-parameters"></span><h3><span class="section-number">7.3.32.4.5. </span>Window function related parameters<a class="headerlink" href="#window-function-related-parameters" title="Permalink to this headline">¶</a></h3>
<div class="versionadded">
<p><span class="versionmodified added">New in version 7.0.9.</span></p>
</div>
<p>All window function related parameters in <a class="reference internal" href="select.html"><span class="doc">select</span></a> are
supported. See <a class="reference internal" href="select.html#select-window-function-related-parameters"><span class="std std-ref">Window function related parameters</span></a> for
details.</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>Window function over multiple tables aren’t supported version 9.0.1 or before.
Groonga supported it since version 9.0.2 or later.
However, we need to align the same order for shard key and leading group key or sort key.</p>
<p>For example, we can apply the window function to over multiple tables as below case.
Because the below example aligns the same order for shard key and leading group key.</p>
<p>The leading group key is <code class="docutils literal notranslate"><span class="pre">price</span></code> and shard key is <code class="docutils literal notranslate"><span class="pre">timestamp</span></code> in the below example.
We can apply the window function to over multiple tables in the below example.
Because <code class="docutils literal notranslate"><span class="pre">price</span></code> and <code class="docutils literal notranslate"><span class="pre">timestamp</span></code> aligns the same order.</p>
</div>
<p>Execution example:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>plugin_register sharding

table_create Logs_20170415 TABLE_NO_KEY
column_create Logs_20170415 timestamp COLUMN_SCALAR Time
column_create Logs_20170415 price COLUMN_SCALAR UInt32
column_create Logs_20170415 n_likes COLUMN_SCALAR UInt32

table_create Logs_20170416 TABLE_NO_KEY
column_create Logs_20170416 timestamp COLUMN_SCALAR Time
column_create Logs_20170416 price COLUMN_SCALAR UInt32
column_create Logs_20170416 n_likes COLUMN_SCALAR UInt32

load --table Logs_20170415
[
{&quot;timestamp&quot;: &quot;2017/04/15 00:00:00&quot;, &quot;n_likes&quot;: 2, &quot;price&quot;: 100},
{&quot;timestamp&quot;: &quot;2017/04/15 01:00:00&quot;, &quot;n_likes&quot;: 1, &quot;price&quot;: 100},
{&quot;timestamp&quot;: &quot;2017/04/15 01:00:00&quot;, &quot;n_likes&quot;: 2, &quot;price&quot;: 200}
]

load --table Logs_20170416
[
{&quot;timestamp&quot;: &quot;2017/04/16 10:00:00&quot;, &quot;n_likes&quot;: 1, &quot;price&quot;: 200},
{&quot;timestamp&quot;: &quot;2017/04/16 11:00:00&quot;, &quot;n_likes&quot;: 2, &quot;price&quot;: 300},
{&quot;timestamp&quot;: &quot;2017/04/16 11:00:00&quot;, &quot;n_likes&quot;: 1, &quot;price&quot;: 300}
]

logical_count Logs \
  --shard_key timestamp \
  --columns[count].stage initial \
  --columns[count].type UInt32 \
  --columns[count].flags COLUMN_SCALAR \
  --columns[count].value &#39;window_count()&#39; \
  --columns[count].window.group_keys price \
  --filter &#39;count &gt;= 1&#39;
# [
#   [
#     0,
#     0.0,
#     0.0
#   ],
#   [
#     4
#   ]
# ]
</pre></div>
</div>
<div class="section" id="columns-name-window-sort-keys">
<span id="logical-count-columns-name-window-sort-keys"></span><h4><span class="section-number">7.3.32.4.5.1. </span><code class="docutils literal notranslate"><span class="pre">columns[${NAME}].window.sort_keys</span></code><a class="headerlink" href="#columns-name-window-sort-keys" title="Permalink to this headline">¶</a></h4>
<div class="versionadded">
<p><span class="versionmodified added">New in version 7.0.9.</span></p>
</div>
<p>Corresponds to <a class="reference internal" href="select.html#select-columns-name-window-sort-keys"><span class="std std-ref">columns[${NAME}].window.sort_keys</span></a> in
<a class="reference internal" href="select.html"><span class="doc">select</span></a>. See <a class="reference internal" href="select.html#select-columns-name-window-sort-keys"><span class="std std-ref">columns[${NAME}].window.sort_keys</span></a> for
details.</p>
<p>You must specify <a class="reference internal" href="#logical-count-columns-name-window-sort-keys"><span class="std std-ref">columns[${NAME}].window.sort_keys</span></a>
or <a class="reference internal" href="#logical-count-columns-name-window-group-keys"><span class="std std-ref">columns[${NAME}].window.group_keys</span></a> to use window
function.</p>
<p>Here is an example that computes cumulative sum per
<code class="docutils literal notranslate"><span class="pre">Entries.tag</span></code>. Each group is sorted by <code class="docutils literal notranslate"><span class="pre">Entries._key</span></code>:</p>
<p>Execution example:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>logical_count \
  --logical_table Entries \
  --shard_key created_at \
  --columns[n_likes_cumulative_sum_per_tag].stage initial \
  --columns[n_likes_cumulative_sum_per_tag].type UInt32 \
  --columns[n_likes_cumulative_sum_per_tag].value &#39;window_sum(n_likes)&#39; \
  --columns[n_likes_cumulative_sum_per_tag].window.sort_keys _key \
  --columns[n_likes_cumulative_sum_per_tag].window.group_keys tag \
  --filter &#39;n_likes_cumulative_sum_per_tag &gt; 5&#39;
# [[0, 1337566253.89858, 0.000355720520019531], 3]
</pre></div>
</div>
</div>
<div class="section" id="columns-name-window-group-keys">
<span id="logical-count-columns-name-window-group-keys"></span><h4><span class="section-number">7.3.32.4.5.2. </span><code class="docutils literal notranslate"><span class="pre">columns[${NAME}].window.group_keys</span></code><a class="headerlink" href="#columns-name-window-group-keys" title="Permalink to this headline">¶</a></h4>
<div class="versionadded">
<p><span class="versionmodified added">New in version 7.0.9.</span></p>
</div>
<p>Corresponds to <a class="reference internal" href="select.html#select-columns-name-window-group-keys"><span class="std std-ref">columns[${NAME}].window.group_keys</span></a> in
<a class="reference internal" href="select.html"><span class="doc">select</span></a>. See <a class="reference internal" href="select.html#select-columns-name-window-group-keys"><span class="std std-ref">columns[${NAME}].window.group_keys</span></a> for
details.</p>
<p>You must specify <a class="reference internal" href="#logical-count-columns-name-window-sort-keys"><span class="std std-ref">columns[${NAME}].window.sort_keys</span></a>
or <a class="reference internal" href="#logical-count-columns-name-window-group-keys"><span class="std std-ref">columns[${NAME}].window.group_keys</span></a> to use window
function.</p>
<p>Here is an example that computes sum per <code class="docutils literal notranslate"><span class="pre">Entries.tag</span></code>:</p>
<p>Execution example:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>logical_count \
  --logical_table Entries \
  --shard_key created_at \
  --columns[n_likes_sum_per_tag].stage initial \
  --columns[n_likes_sum_per_tag].type UInt32 \
  --columns[n_likes_sum_per_tag].value &#39;window_sum(n_likes)&#39; \
  --columns[n_likes_sum_per_tag].window.group_keys tag \
  --filter &#39;n_likes_sum_per_tag &gt; 5&#39;
# [[0, 1337566253.89858, 0.000355720520019531], 4]
</pre></div>
</div>
</div>
</div>
<div class="section" id="cache-related-parameter">
<h3><span class="section-number">7.3.32.4.6. </span>Cache related parameter<a class="headerlink" href="#cache-related-parameter" title="Permalink to this headline">¶</a></h3>
<div class="section" id="cache">
<span id="logical-count-cache"></span><h4><span class="section-number">7.3.32.4.6.1. </span><code class="docutils literal notranslate"><span class="pre">cache</span></code><a class="headerlink" href="#cache" title="Permalink to this headline">¶</a></h4>
<p>Specifies whether caching the result of this query or not.</p>
<p>If the result of this query is cached, the next same query returns
response quickly by using the cache.</p>
<p>It doesn’t control whether existing cached result is used or not.</p>
<p>Here are available values:</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 50%" />
<col style="width: 50%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>Value</p></th>
<th class="head"><p>Description</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">no</span></code></p></td>
<td><p>Don’t cache the output of this query.</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">yes</span></code></p></td>
<td><p>Cache the output of this query.
It’s the default value.</p></td>
</tr>
</tbody>
</table>
<p>Here is an example to disable caching the result of this query:</p>
<p>Execution example:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>logical_count \
  --logical_table Entries \
  --shard_key created_at \
  --cache no
# [[0, 1337566253.89858, 0.000355720520019531], 5]
</pre></div>
</div>
<p>The default value is <code class="docutils literal notranslate"><span class="pre">yes</span></code>.</p>
</div>
</div>
</div>
<div class="section" id="return-value">
<h2><span class="section-number">7.3.32.5. </span>Return value<a class="headerlink" href="#return-value" title="Permalink to this headline">¶</a></h2>
<p>The command returns a response with the following format:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>[HEADER, N_HITS]
</pre></div>
</div>
<p>If the command fails, error details are in <code class="docutils literal notranslate"><span class="pre">HEADER</span></code>.</p>
<p>See <a class="reference internal" href="../command/output_format.html"><span class="doc">Output format</span></a> for <code class="docutils literal notranslate"><span class="pre">HEADER</span></code>.</p>
<p><code class="docutils literal notranslate"><span class="pre">N_HITS</span></code> is the number of matched records.</p>
</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.3.32. <code class="docutils literal notranslate"><span class="pre">logical_count</span></code></a><ul>
<li><a class="reference internal" href="#summary">7.3.32.1. Summary</a></li>
<li><a class="reference internal" href="#syntax">7.3.32.2. Syntax</a></li>
<li><a class="reference internal" href="#usage">7.3.32.3. Usage</a></li>
<li><a class="reference internal" href="#parameters">7.3.32.4. Parameters</a><ul>
<li><a class="reference internal" href="#required-parameters">7.3.32.4.1. Required parameters</a><ul>
<li><a class="reference internal" href="#logical-table">7.3.32.4.1.1. <code class="docutils literal notranslate"><span class="pre">logical_table</span></code></a></li>
<li><a class="reference internal" href="#shard-key">7.3.32.4.1.2. <code class="docutils literal notranslate"><span class="pre">shard_key</span></code></a></li>
</ul>
</li>
<li><a class="reference internal" href="#optional-parameters">7.3.32.4.2. Optional parameters</a><ul>
<li><a class="reference internal" href="#min">7.3.32.4.2.1. <code class="docutils literal notranslate"><span class="pre">min</span></code></a></li>
<li><a class="reference internal" href="#min-border">7.3.32.4.2.2. <code class="docutils literal notranslate"><span class="pre">min_border</span></code></a></li>
<li><a class="reference internal" href="#max">7.3.32.4.2.3. <code class="docutils literal notranslate"><span class="pre">max</span></code></a></li>
<li><a class="reference internal" href="#max-border">7.3.32.4.2.4. <code class="docutils literal notranslate"><span class="pre">max_border</span></code></a></li>
</ul>
</li>
<li><a class="reference internal" href="#search-related-parameters">7.3.32.4.3. Search related parameters</a><ul>
<li><a class="reference internal" href="#filter">7.3.32.4.3.1. <code class="docutils literal notranslate"><span class="pre">filter</span></code></a></li>
<li><a class="reference internal" href="#post-filter">7.3.32.4.3.2. <code class="docutils literal notranslate"><span class="pre">post_filter</span></code></a></li>
</ul>
</li>
<li><a class="reference internal" href="#dynamic-column-related-parameters">7.3.32.4.4. Dynamic column related parameters</a><ul>
<li><a class="reference internal" href="#columns-name-stage">7.3.32.4.4.1. <code class="docutils literal notranslate"><span class="pre">columns[${NAME}].stage</span></code></a></li>
<li><a class="reference internal" href="#columns-name-flags">7.3.32.4.4.2. <code class="docutils literal notranslate"><span class="pre">columns[${NAME}].flags</span></code></a></li>
<li><a class="reference internal" href="#columns-name-type">7.3.32.4.4.3. <code class="docutils literal notranslate"><span class="pre">columns[${NAME}].type</span></code></a></li>
<li><a class="reference internal" href="#columns-name-value">7.3.32.4.4.4. <code class="docutils literal notranslate"><span class="pre">columns[${NAME}].value</span></code></a></li>
</ul>
</li>
<li><a class="reference internal" href="#window-function-related-parameters">7.3.32.4.5. Window function related parameters</a><ul>
<li><a class="reference internal" href="#columns-name-window-sort-keys">7.3.32.4.5.1. <code class="docutils literal notranslate"><span class="pre">columns[${NAME}].window.sort_keys</span></code></a></li>
<li><a class="reference internal" href="#columns-name-window-group-keys">7.3.32.4.5.2. <code class="docutils literal notranslate"><span class="pre">columns[${NAME}].window.group_keys</span></code></a></li>
</ul>
</li>
<li><a class="reference internal" href="#cache-related-parameter">7.3.32.4.6. Cache related parameter</a><ul>
<li><a class="reference internal" href="#cache">7.3.32.4.6.1. <code class="docutils literal notranslate"><span class="pre">cache</span></code></a></li>
</ul>
</li>
</ul>
</li>
<li><a class="reference internal" href="#return-value">7.3.32.5. Return value</a></li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="log_reopen.html"
                        title="previous chapter"><span class="section-number">7.3.31. </span><code class="docutils literal notranslate"><span class="pre">log_reopen</span></code></a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="logical_parameters.html"
                        title="next chapter"><span class="section-number">7.3.33. </span><code class="docutils literal notranslate"><span class="pre">logical_parameters</span></code></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="logical_parameters.html" title="7.3.33. logical_parameters"
             >next</a> |</li>
        <li class="right" >
          <a href="log_reopen.html" title="7.3.31. log_reopen"
             >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="../command.html" ><span class="section-number">7.3. </span>Command</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href=""><span class="section-number">7.3.32. </span><code class="docutils literal notranslate"><span class="pre">logical_count</span></code></a></li> 
      </ul>
    </div>
    <div class="footer" role="contentinfo">
        &#169; Copyright 2009-2021, Brazil, Inc.
    </div>
  </body>
</html>