File: column_create.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 (1206 lines) | stat: -rw-r--r-- 70,637 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
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206


<!DOCTYPE html>

<html lang="en">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>7.3.11. column_create &#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.12. column_list" href="column_list.html" />
    <link rel="prev" title="7.3.10. column_copy" href="column_copy.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/column_create.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="column_list.html" title="7.3.12. column_list"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="column_copy.html" title="7.3.10. column_copy"
             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.11. </span><code class="docutils literal notranslate"><span class="pre">column_create</span></code></a></li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body" role="main">
            
  <div class="section" id="column-create">
<h1><span class="section-number">7.3.11. </span><code class="docutils literal notranslate"><span class="pre">column_create</span></code><a class="headerlink" href="#column-create" title="Permalink to this headline">¶</a></h1>
<div class="section" id="summary">
<h2><span class="section-number">7.3.11.1. </span>Summary<a class="headerlink" href="#summary" title="Permalink to this headline">¶</a></h2>
<p><code class="docutils literal notranslate"><span class="pre">column_create</span></code> creates a new column in a table.</p>
<p>You need to create one or more columns to store multiple data in one
record.</p>
<p>Groonga provides an index as a column. It’s different from other
systems. An index is just an index in other systems. Implementing an
index as a column provides flexibility. For example, you can add
metadata to each token.</p>
<p>See <a class="reference internal" href="../column.html"><span class="doc">Column</span></a> for column details.</p>
</div>
<div class="section" id="syntax">
<h2><span class="section-number">7.3.11.2. </span>Syntax<a class="headerlink" href="#syntax" title="Permalink to this headline">¶</a></h2>
<p>This command takes many parameters.</p>
<p>Most parameters are required:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>column_create table
              name
              flags
              type
              [source=null]
              [path=null]
</pre></div>
</div>
</div>
<div class="section" id="usage">
<h2><span class="section-number">7.3.11.3. </span>Usage<a class="headerlink" href="#usage" title="Permalink to this headline">¶</a></h2>
<p>This section describes about the followings:</p>
<blockquote>
<div><ul class="simple">
<li><p><a class="reference internal" href="#column-create-scalar"><span class="std std-ref">Create a scalar column</span></a></p></li>
<li><p><a class="reference internal" href="#column-create-vector"><span class="std std-ref">Create a vector column</span></a></p></li>
<li><p><a class="reference internal" href="#column-create-vector-weight"><span class="std std-ref">Create a weight vector column</span></a></p></li>
<li><p><a class="reference internal" href="#column-create-reference"><span class="std std-ref">Create a column that refers a table’s record</span></a></p></li>
<li><p><a class="reference internal" href="#column-create-index"><span class="std std-ref">Create an index column</span></a></p></li>
<li><p><a class="reference internal" href="#column-create-index-full-text-search"><span class="std std-ref">Create an index column for full text search</span></a></p></li>
<li><p><a class="reference internal" href="#column-create-index-multiple-columns"><span class="std std-ref">Create a multiple columns index column</span></a></p></li>
<li><p><a class="reference internal" href="#column-create-index-small"><span class="std std-ref">Create a small index column</span></a></p></li>
<li><p><a class="reference internal" href="#column-create-index-medium"><span class="std std-ref">Create a medium index column</span></a></p></li>
<li><p><a class="reference internal" href="#column-create-index-large"><span class="std std-ref">Create a large index column</span></a></p></li>
</ul>
</div></blockquote>
<p>Here is the <code class="docutils literal notranslate"><span class="pre">People</span></code> table definition. The <code class="docutils literal notranslate"><span class="pre">People</span></code> table is used
in examples:</p>
<p>Execution example:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>table_create \
  --name People \
  --flags TABLE_HASH_KEY \
  --key_type ShortText
# [[0, 1337566253.89858, 0.000355720520019531], true]
</pre></div>
</div>
<div class="section" id="create-a-scalar-column">
<span id="column-create-scalar"></span><h3><span class="section-number">7.3.11.3.1. </span>Create a scalar column<a class="headerlink" href="#create-a-scalar-column" title="Permalink to this headline">¶</a></h3>
<p>Groonga provides scalar column to store one value. For example, scalar
column should be used for storing age into a person record. Because a
person record must have only one age.</p>
<p>If you want to store multiple values into a record, scalar column
isn’t suitable. Use <a class="reference internal" href="#column-create-vector"><span class="std std-ref">Create a vector column</span></a> instead.</p>
<p>You must specify <code class="docutils literal notranslate"><span class="pre">COLUMN_SCALAR</span></code> to the <code class="docutils literal notranslate"><span class="pre">flags</span></code> parameter to
create a scalar column.</p>
<p>Here is an example to create the <code class="docutils literal notranslate"><span class="pre">age</span></code> column to the <code class="docutils literal notranslate"><span class="pre">People</span></code>
table. <code class="docutils literal notranslate"><span class="pre">age</span></code> column is a scalar column. It can store one <code class="docutils literal notranslate"><span class="pre">UInt8</span></code>
(<code class="docutils literal notranslate"><span class="pre">0-255</span></code>) value as its value:</p>
<p>Execution example:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>column_create \
  --table People \
  --name age \
  --flags COLUMN_SCALAR \
  --type UInt8
# [[0, 1337566253.89858, 0.000355720520019531], true]
</pre></div>
</div>
<p>You can store one value (<code class="docutils literal notranslate"><span class="pre">7</span></code>) by the following <a class="reference internal" href="load.html"><span class="doc">load</span></a> command:</p>
<p>Execution example:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>load --table People
[
{&quot;_key&quot;: &quot;alice&quot;, &quot;age&quot;: 7}
]
# [[0, 1337566253.89858, 0.000355720520019531], 1]
</pre></div>
</div>
<p>You can confirm the stored one value (<code class="docutils literal notranslate"><span class="pre">7</span></code>) by the following
<a class="reference internal" href="select.html"><span class="doc">select</span></a> command:</p>
<p>Execution example:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>select --table People
# [
#   [
#     0,
#     1337566253.89858,
#     0.000355720520019531
#   ],
#   [
#     [
#       [
#         1
#       ],
#       [
#         [
#           &quot;_id&quot;,
#           &quot;UInt32&quot;
#         ],
#         [
#           &quot;_key&quot;,
#           &quot;ShortText&quot;
#         ],
#         [
#           &quot;age&quot;,
#           &quot;UInt8&quot;
#         ]
#       ],
#       [
#         1,
#         &quot;alice&quot;,
#         7
#       ]
#     ]
#   ]
# ]
</pre></div>
</div>
</div>
<div class="section" id="create-a-vector-column">
<span id="column-create-vector"></span><h3><span class="section-number">7.3.11.3.2. </span>Create a vector column<a class="headerlink" href="#create-a-vector-column" title="Permalink to this headline">¶</a></h3>
<p>Groonga provides vector column to store multiple values. For example,
vector column may be used for storing roles into a person
record. Because a person record may have multiple roles.</p>
<p>If you want to store only one value into a record, vector column isn’t
suitable. Use <a class="reference internal" href="#column-create-scalar"><span class="std std-ref">Create a scalar column</span></a> instead.</p>
<p>You must specify <code class="docutils literal notranslate"><span class="pre">COLUMN_VECTOR</span></code> to the <code class="docutils literal notranslate"><span class="pre">flags</span></code> parameter to
create a vector column.</p>
<p>Here is an example to create the <code class="docutils literal notranslate"><span class="pre">roles</span></code> column to the <code class="docutils literal notranslate"><span class="pre">People</span></code>
table. <code class="docutils literal notranslate"><span class="pre">roles</span></code> column is a vector column. It can store zero or more
<code class="docutils literal notranslate"><span class="pre">ShortText</span></code> values as its value:</p>
<p>Execution example:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>column_create \
  --table People \
  --name roles \
  --flags COLUMN_VECTOR \
  --type ShortText
# [[0, 1337566253.89858, 0.000355720520019531], true]
</pre></div>
</div>
<p>You can store multiple values (<code class="docutils literal notranslate"><span class="pre">[&quot;adventurer&quot;,</span> <span class="pre">&quot;younger-sister&quot;]</span></code>)
by the following <a class="reference internal" href="load.html"><span class="doc">load</span></a> command:</p>
<p>Execution example:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>load --table People
[
{&quot;_key&quot;: &quot;alice&quot;, &quot;roles&quot;: [&quot;adventurer&quot;, &quot;younger-sister&quot;]}
]
# [[0, 1337566253.89858, 0.000355720520019531], 1]
</pre></div>
</div>
<p>You can confirm the stored multiple values (<code class="docutils literal notranslate"><span class="pre">[&quot;adventurer&quot;,</span>
<span class="pre">&quot;younger-sister&quot;]</span></code>) by the following <a class="reference internal" href="select.html"><span class="doc">select</span></a> command:</p>
<p>Execution example:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>select --table People
# [
#   [
#     0,
#     1337566253.89858,
#     0.000355720520019531
#   ],
#   [
#     [
#       [
#         1
#       ],
#       [
#         [
#           &quot;_id&quot;,
#           &quot;UInt32&quot;
#         ],
#         [
#           &quot;_key&quot;,
#           &quot;ShortText&quot;
#         ],
#         [
#           &quot;age&quot;,
#           &quot;UInt8&quot;
#         ],
#         [
#           &quot;roles&quot;,
#           &quot;ShortText&quot;
#         ]
#       ],
#       [
#         1,
#         &quot;alice&quot;,
#         7,
#         [
#           &quot;adventurer&quot;,
#           &quot;younger-sister&quot;
#         ]
#       ]
#     ]
#   ]
# ]
</pre></div>
</div>
</div>
<div class="section" id="create-a-weight-vector-column">
<span id="column-create-vector-weight"></span><h3><span class="section-number">7.3.11.3.3. </span>Create a weight vector column<a class="headerlink" href="#create-a-weight-vector-column" title="Permalink to this headline">¶</a></h3>
<p>TODO: See also <a class="reference internal" href="../columns/vector.html#weight-vector-column"><span class="std std-ref">Weight vector column</span></a> and <a class="reference internal" href="select.html#select-adjuster"><span class="std std-ref">adjuster</span></a>.</p>
</div>
<div class="section" id="create-a-column-that-refers-a-table-s-record">
<span id="column-create-reference"></span><h3><span class="section-number">7.3.11.3.4. </span>Create a column that refers a table’s record<a class="headerlink" href="#create-a-column-that-refers-a-table-s-record" title="Permalink to this headline">¶</a></h3>
<p>Both scalar column and vector column can store reference to record of
an existing table as column value. It’s useful to store relationship
between records.</p>
<p>For example, using a column that refers a person record is better for
storing a character into a book record. Because one person may be
appeared in some books.</p>
<p>You must specify table name to be referenced to the <code class="docutils literal notranslate"><span class="pre">type</span></code> parameter
to create a column that refers a table’s record.</p>
<p>Here is an example to create the <code class="docutils literal notranslate"><span class="pre">character</span></code> column to the <code class="docutils literal notranslate"><span class="pre">Books</span></code>
table. The <code class="docutils literal notranslate"><span class="pre">character</span></code> column refers the <code class="docutils literal notranslate"><span class="pre">People</span></code> table. It can
store one <code class="docutils literal notranslate"><span class="pre">People</span></code> table’s record.</p>
<p>Here is the <code class="docutils literal notranslate"><span class="pre">Books</span></code> table definition:</p>
<p>Execution example:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>table_create \
  --name Books \
  --flags TABLE_HASH_KEY \
  --key_type ShortText
# [[0, 1337566253.89858, 0.000355720520019531], true]
</pre></div>
</div>
<p>Here is the <code class="docutils literal notranslate"><span class="pre">character</span></code> column definition in the <code class="docutils literal notranslate"><span class="pre">Books</span></code>
table. <code class="docutils literal notranslate"><span class="pre">--type</span> <span class="pre">People</span></code> is important:</p>
<p>Execution example:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>column_create \
  --table Books \
  --name character \
  --flags COLUMN_SCALAR \
  --type People
# [[0, 1337566253.89858, 0.000355720520019531], true]
</pre></div>
</div>
<p>You can store one reference (<code class="docutils literal notranslate"><span class="pre">&quot;alice&quot;</span></code>) by the following <a class="reference internal" href="load.html"><span class="doc">load</span></a>
command. You can use key value (<code class="docutils literal notranslate"><span class="pre">People._key</span></code> value) for referring a
record:</p>
<p>Execution example:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>load --table Books
[
{&quot;_key&quot;: &quot;Alice&#39;s Adventure in Wonderland&quot;, &quot;character&quot;: &quot;alice&quot;}
]
# [[0, 1337566253.89858, 0.000355720520019531], 1]
</pre></div>
</div>
<p>You can confirm the stored reference (<code class="docutils literal notranslate"><span class="pre">&quot;alice&quot;</span></code> record) by the
following <a class="reference internal" href="select.html"><span class="doc">select</span></a> command. It retrieves the <code class="docutils literal notranslate"><span class="pre">age</span></code> column and
the <code class="docutils literal notranslate"><span class="pre">roles</span></code> column values:</p>
<p>Execution example:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>select \
 --table Books \
 --output_columns _key,character._key,character.age,character.roles
# [
#   [
#     0,
#     1337566253.89858,
#     0.000355720520019531
#   ],
#   [
#     [
#       [
#         1
#       ],
#       [
#         [
#           &quot;_key&quot;,
#           &quot;ShortText&quot;
#         ],
#         [
#           &quot;character._key&quot;,
#           &quot;ShortText&quot;
#         ],
#         [
#           &quot;character.age&quot;,
#           &quot;UInt8&quot;
#         ],
#         [
#           &quot;character.roles&quot;,
#           &quot;ShortText&quot;
#         ]
#       ],
#       [
#         &quot;Alice&#39;s Adventure in Wonderland&quot;,
#         &quot;alice&quot;,
#         7,
#         [
#           &quot;adventurer&quot;,
#           &quot;younger-sister&quot;
#         ]
#       ]
#     ]
#   ]
# ]
</pre></div>
</div>
</div>
<div class="section" id="create-an-index-column">
<span id="column-create-index"></span><h3><span class="section-number">7.3.11.3.5. </span>Create an index column<a class="headerlink" href="#create-an-index-column" title="Permalink to this headline">¶</a></h3>
<p>Groonga provides index column for fast search. It doesn’t store your
data. It stores data for fast search.</p>
<p>You don’t need to update index column by yourself. Index column is
updated automatically when you store data into a data column (scalar
column or vector column) that is marked as index target column. You
can set multiple columns as index target columns to one index column.</p>
<p>If you make a new index, it is invisible until finishing of index build.</p>
<p>If Groonga has an index column for the <code class="docutils literal notranslate"><span class="pre">age</span></code> column of the
<code class="docutils literal notranslate"><span class="pre">People</span></code> table, Groonga can do fast equal search, fast comparison
search and fast range search against <code class="docutils literal notranslate"><span class="pre">age</span></code> column values.</p>
<p>You must specify the following parameters to create an index column:</p>
<blockquote>
<div><ul class="simple">
<li><p>The <code class="docutils literal notranslate"><span class="pre">flags</span></code> parameter: <code class="docutils literal notranslate"><span class="pre">COLUMN_INDEX</span></code></p></li>
<li><p>The <code class="docutils literal notranslate"><span class="pre">type</span></code> parameter: The table name of index target column such
as <code class="docutils literal notranslate"><span class="pre">People</span></code></p></li>
<li><p>The <code class="docutils literal notranslate"><span class="pre">source</span></code> parameter: The index target column name such as
<code class="docutils literal notranslate"><span class="pre">age</span></code></p></li>
</ul>
</div></blockquote>
<p>You don’t need additional flags to the <code class="docutils literal notranslate"><span class="pre">flags</span></code> parameter for equal
search, comparison search and range search index column. You need
additional flags to the <code class="docutils literal notranslate"><span class="pre">flags</span></code> parameter for full text search index
column or multiple column index column. See
<a class="reference internal" href="#column-create-index-full-text-search"><span class="std std-ref">Create an index column for full text search</span></a> and
<a class="reference internal" href="#column-create-index-multiple-columns"><span class="std std-ref">Create a multiple columns index column</span></a> for details.</p>
<p>Here is an example to create an index column for the <code class="docutils literal notranslate"><span class="pre">age</span></code> column of
the <code class="docutils literal notranslate"><span class="pre">People</span></code> table.</p>
<p>First, you need to create a table for range index column. See
<a class="reference internal" href="table_create.html#table-create-range-index-table"><span class="std std-ref">Create range index table</span></a> for details. This example
creates the <code class="docutils literal notranslate"><span class="pre">Ages</span></code> table as <a class="reference internal" href="../tables.html#table-pat-key"><span class="std std-ref">TABLE_PAT_KEY</span></a>:</p>
<p>Execution example:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>table_create \
  --name Ages \
  --flags TABLE_PAT_KEY \
  --key_type UInt8
# [[0, 1337566253.89858, 0.000355720520019531], true]
</pre></div>
</div>
<p>Now, you can create an index column for the <code class="docutils literal notranslate"><span class="pre">age</span></code> column of the
<code class="docutils literal notranslate"><span class="pre">People</span></code> table. <code class="docutils literal notranslate"><span class="pre">COLUMN_INDEX</span></code> in the <code class="docutils literal notranslate"><span class="pre">flags</span></code> parameter,
<code class="docutils literal notranslate"><span class="pre">People</span></code> in the <code class="docutils literal notranslate"><span class="pre">type</span></code> parameter and <code class="docutils literal notranslate"><span class="pre">age</span></code> in the <code class="docutils literal notranslate"><span class="pre">source</span></code>
parameter are important:</p>
<p>Execution example:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>column_create \
  --table Ages \
  --name people_age_index \
  --flags COLUMN_INDEX \
  --type People \
  --source age
# [[0, 1337566253.89858, 0.000355720520019531], true]
</pre></div>
</div>
<p>You can confirm that <code class="docutils literal notranslate"><span class="pre">age</span> <span class="pre">&gt;</span> <span class="pre">5</span></code> is evaluated by the
<code class="docutils literal notranslate"><span class="pre">Ages.people_age_index</span></code> newly created index column from log. Groonga
reports used index columns in <code class="docutils literal notranslate"><span class="pre">info</span></code> log level. You can change log
level dynamically by <a class="reference internal" href="log_level.html"><span class="doc">log_level</span></a> command.</p>
<p>Execution example:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>log_level --level info
# [[0, 1337566253.89858, 0.000355720520019531], true]
select \
  --table People \
  --filter &#39;age &gt; 5&#39;
# [
#   [
#     0,
#     1337566253.89858,
#     0.000355720520019531
#   ],
#   [
#     [
#       [
#         1
#       ],
#       [
#         [
#           &quot;_id&quot;,
#           &quot;UInt32&quot;
#         ],
#         [
#           &quot;_key&quot;,
#           &quot;ShortText&quot;
#         ],
#         [
#           &quot;age&quot;,
#           &quot;UInt8&quot;
#         ],
#         [
#           &quot;roles&quot;,
#           &quot;ShortText&quot;
#         ]
#       ],
#       [
#         1,
#         &quot;alice&quot;,
#         7,
#         [
#           &quot;adventurer&quot;,
#           &quot;younger-sister&quot;
#         ]
#       ]
#     ]
#   ]
# ]
# log: 2019-04-02 18:35:32.349471|i| [table][select][index][range] &lt;Ages.people_age_index&gt;
log_level --level notice
# [[0, 1337566253.89858, 0.000355720520019531], true]
</pre></div>
</div>
<p>You can confirm that the <code class="docutils literal notranslate"><span class="pre">Ages.people_age_index</span></code> is used from the
following log:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>[table][select][index][range] &lt;Ages.people_age_index&gt;
</pre></div>
</div>
<p>The log says <code class="docutils literal notranslate"><span class="pre">Ages.people_age_index</span></code> index column is used for range
search.</p>
</div>
<div class="section" id="create-an-index-column-for-full-text-search">
<span id="column-create-index-full-text-search"></span><h3><span class="section-number">7.3.11.3.6. </span>Create an index column for full text search<a class="headerlink" href="#create-an-index-column-for-full-text-search" title="Permalink to this headline">¶</a></h3>
<p>There is a difference between for non full text search (equal search,
comparison search or range search) index column and for full text
search index column. You need to add <code class="docutils literal notranslate"><span class="pre">WITH_POSITION</span></code> to the
<code class="docutils literal notranslate"><span class="pre">flags</span></code> parameter. It means that you need to specify
<code class="docutils literal notranslate"><span class="pre">COLUMN_INDEX|WITH_POSITION</span></code> to the <code class="docutils literal notranslate"><span class="pre">flags</span></code> parameter. It’s the
difference.</p>
<p>Here is an example to create a full text search index column for the
key of the <code class="docutils literal notranslate"><span class="pre">People</span></code> table.</p>
<p>First, you need to create a table for full text search index
column. See <a class="reference internal" href="table_create.html#table-create-lexicon"><span class="std std-ref">Create lexicon</span></a> for details. This example
creates the <code class="docutils literal notranslate"><span class="pre">Terms</span></code> table as <a class="reference internal" href="../tables.html#table-pat-key"><span class="std std-ref">TABLE_PAT_KEY</span></a> with
<a class="reference internal" href="../tokenizers/token_bigram.html#token-bigram"><span class="std std-ref">TokenBigram</span></a> tokenizer and <a class="reference internal" href="../normalizers/normalizer_auto.html#normalizer-auto"><span class="std std-ref">NormalizerAuto</span></a> normalizer:</p>
<p>Execution example:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>table_create \
  --name Terms \
  --flags TABLE_PAT_KEY \
  --key_type ShortText \
  --default_tokenizer TokenBigram \
  --normalizer NormalizerAuto
# [[0, 1337566253.89858, 0.000355720520019531], true]
</pre></div>
</div>
<p>Now, you can create a full text search index column for the key of the
<code class="docutils literal notranslate"><span class="pre">People</span></code> table. <code class="docutils literal notranslate"><span class="pre">COLUMN_INDEX|WITH_POSITION</span></code> in the <code class="docutils literal notranslate"><span class="pre">flags</span></code>
parameter, <code class="docutils literal notranslate"><span class="pre">People</span></code> in the <code class="docutils literal notranslate"><span class="pre">type</span></code> parameter and <code class="docutils literal notranslate"><span class="pre">_key</span></code> in the
<code class="docutils literal notranslate"><span class="pre">source</span></code> parameter are important:</p>
<p>Execution example:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>column_create \
  --table Terms \
  --name people_key_index \
  --flags COLUMN_INDEX|WITH_POSITION \
  --type People \
  --source _key
# [[0, 1337566253.89858, 0.000355720520019531], true]
</pre></div>
</div>
<p>You can confirm that <code class="docutils literal notranslate"><span class="pre">--match_columns</span> <span class="pre">_key</span></code> and <code class="docutils literal notranslate"><span class="pre">--query</span> <span class="pre">Alice</span></code>
are evaluated by the <code class="docutils literal notranslate"><span class="pre">Terms.people_key_index</span></code> newly created full
text search index column from log. Groonga reports used index columns
in <code class="docutils literal notranslate"><span class="pre">info</span></code> log level. You can change log level dynamically by
<a class="reference internal" href="log_level.html"><span class="doc">log_level</span></a> command.</p>
<p>Execution example:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>log_level --level info
# [[0, 1337566253.89858, 0.000355720520019531], true]
select \
  --table People \
  --match_columns _key \
  --query Alice
# [
#   [
#     0,
#     1337566253.89858,
#     0.000355720520019531
#   ],
#   [
#     [
#       [
#         1
#       ],
#       [
#         [
#           &quot;_id&quot;,
#           &quot;UInt32&quot;
#         ],
#         [
#           &quot;_key&quot;,
#           &quot;ShortText&quot;
#         ],
#         [
#           &quot;age&quot;,
#           &quot;UInt8&quot;
#         ],
#         [
#           &quot;roles&quot;,
#           &quot;ShortText&quot;
#         ]
#       ],
#       [
#         1,
#         &quot;alice&quot;,
#         7,
#         [
#           &quot;adventurer&quot;,
#           &quot;younger-sister&quot;
#         ]
#       ]
#     ]
#   ]
# ]
# log: 2019-04-02 18:35:33.044069|i| [object][search][index][key][exact] &lt;Terms.people_key_index&gt;
# log: 2019-04-02 18:35:33.044114|i| grn_ii_sel &gt; (Alice)
# log: 2019-04-02 18:35:33.044226|i| n=1 (Alice)
# log: 2019-04-02 18:35:33.044305|i| exact: 1
# log: 2019-04-02 18:35:33.044318|i| hits=1
log_level --level notice
# [[0, 1337566253.89858, 0.000355720520019531], true]
</pre></div>
</div>
<p>You can confirm that the <code class="docutils literal notranslate"><span class="pre">Terms.people_key_index</span></code> is used from the
following log:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>[object][search][index][key][exact] &lt;Terms.people_key_index&gt;
</pre></div>
</div>
<p>The log says <code class="docutils literal notranslate"><span class="pre">Terms.people_key_index</span></code> index column is used for full
text search. (To be precise, the index column is used for exact term
search by inverted index.)</p>
</div>
<div class="section" id="create-a-multiple-columns-index-column">
<span id="column-create-index-multiple-columns"></span><h3><span class="section-number">7.3.11.3.7. </span>Create a multiple columns index column<a class="headerlink" href="#create-a-multiple-columns-index-column" title="Permalink to this headline">¶</a></h3>
<p>You can create an index column for multiple columns. It means that you
can do fast search for multiple columns with one index
column. Multiple columns index column has better space efficiency than
single column index column only when multiple columns have many same
tokens. Multiple columns index column may be slower than single column
index column. Because multiple columns index column will be a bigger
index column.</p>
<p>You can’t use multiples columns in different tables as index target
columns in the same multiple columns index column. You must specify
columns in the same tables as index target columns to one multiple
columns index column. For example, you can’t create a multiple columns
index for <code class="docutils literal notranslate"><span class="pre">People._key</span></code> and <code class="docutils literal notranslate"><span class="pre">Books._key</span></code> because they are columns
of different tables. You can create a multiple columns index column
for <code class="docutils literal notranslate"><span class="pre">People._key</span></code> and <code class="docutils literal notranslate"><span class="pre">People.roles</span></code> because they are columns of
the same table.</p>
<p>There is a difference between for single column index column and for
multiple columns index column. You need to add <code class="docutils literal notranslate"><span class="pre">WITH_SECTION</span></code> to the
<code class="docutils literal notranslate"><span class="pre">flags</span></code> parameter. It means that you need to specify
<code class="docutils literal notranslate"><span class="pre">COLUMN_INDEX|WITH_SECTION</span></code> to the <code class="docutils literal notranslate"><span class="pre">flags</span></code> parameter. It’s the
difference.</p>
<p>If you want to create a multiple columns index column for full text
search, you need to specify
<code class="docutils literal notranslate"><span class="pre">COLUMN_INDEX|WITH_POSITION|WITH_SECTION</span></code> to the <code class="docutils literal notranslate"><span class="pre">flags</span></code>
parameter. See <a class="reference internal" href="#column-create-index-full-text-search"><span class="std std-ref">Create an index column for full text search</span></a> for full
text search index column details.</p>
<p>Here is an example to create a multiple columns index column for the
key of the <code class="docutils literal notranslate"><span class="pre">People</span></code> table and the <code class="docutils literal notranslate"><span class="pre">roles</span></code> column of the <code class="docutils literal notranslate"><span class="pre">People</span></code>
table.</p>
<p>There is no difference between index table for single column index
column and multiple columns index column.</p>
<p>In this example, <code class="docutils literal notranslate"><span class="pre">Names</span></code> table is created for equal search and
prefix search. It uses <code class="docutils literal notranslate"><span class="pre">TABLE_PAT_KEY</span></code> because <code class="docutils literal notranslate"><span class="pre">TABLE_PAT_KEY</span></code>
supports prefix search. See <a class="reference internal" href="../tables.html"><span class="doc">Tables</span></a> for details.</p>
<p>Execution example:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>table_create \
  --name Names \
  --flags TABLE_PAT_KEY \
  --key_type ShortText \
  --normalizer NormalizerAuto
# [[0, 1337566253.89858, 0.000355720520019531], true]
</pre></div>
</div>
<p>You can create a multiple columns index column for the key of the
<code class="docutils literal notranslate"><span class="pre">People</span></code> table and <code class="docutils literal notranslate"><span class="pre">roles</span></code> column of the <code class="docutils literal notranslate"><span class="pre">People</span></code>
table. <code class="docutils literal notranslate"><span class="pre">COLUMN_INDEX|WITH_SECTION</span></code> in the <code class="docutils literal notranslate"><span class="pre">flags</span></code> parameter,
<code class="docutils literal notranslate"><span class="pre">People</span></code> in the <code class="docutils literal notranslate"><span class="pre">type</span></code> parameter and <code class="docutils literal notranslate"><span class="pre">_key,roles</span></code> in the
<code class="docutils literal notranslate"><span class="pre">source</span></code> parameter are important:</p>
<p>Execution example:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>column_create \
  --table Names \
  --name people_key_roles_index \
  --flags COLUMN_INDEX|WITH_SECTION \
  --type People \
  --source _key,roles
# [[0, 1337566253.89858, 0.000355720520019531], true]
</pre></div>
</div>
<p>You can confirm that <code class="docutils literal notranslate"><span class="pre">--filter</span> <span class="pre">'roles</span> <span class="pre">&#64;^</span> <span class="pre">&quot;Younger&quot;</span></code> is evaluated by
the <code class="docutils literal notranslate"><span class="pre">Names.people_key_roles_index</span></code> newly created multiple columns
index column from log. Groonga reports used index columns in <code class="docutils literal notranslate"><span class="pre">info</span></code>
log level. You can change log level dynamically by <a class="reference internal" href="log_level.html"><span class="doc">log_level</span></a>
command.</p>
<p>Execution example:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>log_level --level info
# [[0, 1337566253.89858, 0.000355720520019531], true]
select \
  --table People \
  --filter &#39;roles @^ &quot;Younger&quot;&#39;
# [
#   [
#     0,
#     1337566253.89858,
#     0.000355720520019531
#   ],
#   [
#     [
#       [
#         1
#       ],
#       [
#         [
#           &quot;_id&quot;,
#           &quot;UInt32&quot;
#         ],
#         [
#           &quot;_key&quot;,
#           &quot;ShortText&quot;
#         ],
#         [
#           &quot;age&quot;,
#           &quot;UInt8&quot;
#         ],
#         [
#           &quot;roles&quot;,
#           &quot;ShortText&quot;
#         ]
#       ],
#       [
#         1,
#         &quot;alice&quot;,
#         7,
#         [
#           &quot;adventurer&quot;,
#           &quot;younger-sister&quot;
#         ]
#       ]
#     ]
#   ]
# ]
# log: 2019-04-02 18:35:33.728665|i| [table][select][index][prefix] &lt;Names.people_key_roles_index&gt;
log_level --level notice
# [[0, 1337566253.89858, 0.000355720520019531], true]
</pre></div>
</div>
<p>You can confirm that the <code class="docutils literal notranslate"><span class="pre">Names.people_key_roles_index</span></code> is used from
the following log:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>[table][select][index][prefix] &lt;Names.people_key_roles_index&gt;
</pre></div>
</div>
<p>The log says <code class="docutils literal notranslate"><span class="pre">Names.people_key_roles_index</span></code> index column is used for
prefix search.</p>
</div>
<div class="section" id="create-a-small-index-column">
<span id="column-create-index-small"></span><h3><span class="section-number">7.3.11.3.8. </span>Create a small index column<a class="headerlink" href="#create-a-small-index-column" title="Permalink to this headline">¶</a></h3>
<p>If you know index target data are small, you can reduce memory usage
for the index column. Memory usage is <code class="docutils literal notranslate"><span class="pre">1/256</span></code> of the default index
column.</p>
<p>How many data are small? It depends on data. Small index column can’t
handle 1 billion records at least. If index target is only one
scalar column with no text family type (<code class="docutils literal notranslate"><span class="pre">ShortText</span></code>, <code class="docutils literal notranslate"><span class="pre">Text</span></code> or
<code class="docutils literal notranslate"><span class="pre">LongText</span></code>), the maximum handleable records are depends of the
number of kinds of index target data. If index target column has
<code class="docutils literal notranslate"><span class="pre">1</span></code>, <code class="docutils literal notranslate"><span class="pre">1</span></code>, <code class="docutils literal notranslate"><span class="pre">2</span></code> and <code class="docutils literal notranslate"><span class="pre">3</span></code>, the number of kinds of them are <code class="docutils literal notranslate"><span class="pre">3</span></code>
(<code class="docutils literal notranslate"><span class="pre">1</span></code> and <code class="docutils literal notranslate"><span class="pre">2</span></code> and <code class="docutils literal notranslate"><span class="pre">3</span></code>). The following table shows the
relationship between the number of kinds of index target data and the
number of handleable records:</p>
<table class="docutils align-default" id="id1">
<caption><span class="caption-text">The number of kinds of index target data and the number of handleable records in a small index column</span><a class="headerlink" href="#id1" title="Permalink to this table">¶</a></caption>
<colgroup>
<col style="width: 50%" />
<col style="width: 50%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>The number of kinds of index target data</p></th>
<th class="head"><p>The number of hanleable records</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>1</p></td>
<td><p>16779234</p></td>
</tr>
<tr class="row-odd"><td><p>2</p></td>
<td><p>4648070</p></td>
</tr>
<tr class="row-even"><td><p>4</p></td>
<td><p>7238996</p></td>
</tr>
<tr class="row-odd"><td><p>8</p></td>
<td><p>8308622</p></td>
</tr>
<tr class="row-even"><td><p>16</p></td>
<td><p>11068624</p></td>
</tr>
<tr class="row-odd"><td><p>32</p></td>
<td><p>12670817</p></td>
</tr>
<tr class="row-even"><td><p>64</p></td>
<td><p>18524211</p></td>
</tr>
<tr class="row-odd"><td><p>128</p></td>
<td><p>38095511</p></td>
</tr>
<tr class="row-even"><td><p>256</p></td>
<td><p>51265384</p></td>
</tr>
</tbody>
</table>
<p>You need to add <code class="docutils literal notranslate"><span class="pre">INDEX_SMALL</span></code> to the <code class="docutils literal notranslate"><span class="pre">flags</span></code> parameter such as
<code class="docutils literal notranslate"><span class="pre">COLUMN_INDEX|INDEX_SMALL</span></code> to create a small index column.</p>
<p>If the <code class="docutils literal notranslate"><span class="pre">People</span></code> table has only 1 million records, you can use a
small index column for the <code class="docutils literal notranslate"><span class="pre">age</span></code> column:</p>
<p>Execution example:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>column_create \
  --table Ages \
  --name people_age_small_index \
  --flags COLUMN_INDEX|INDEX_SMALL \
  --type People \
  --source age
# [[0, 1337566253.89858, 0.000355720520019531], true]
</pre></div>
</div>
</div>
<div class="section" id="create-a-medium-index-column">
<span id="column-create-index-medium"></span><h3><span class="section-number">7.3.11.3.9. </span>Create a medium index column<a class="headerlink" href="#create-a-medium-index-column" title="Permalink to this headline">¶</a></h3>
<p>If you know index target data are medium, you can reduce memory usage
for the index column. Memory usage is <code class="docutils literal notranslate"><span class="pre">5/24</span></code> of the default index
column.</p>
<p>How many data are medium? It depends on data.</p>
<p>If index target is only one scalar column, a medium index column
can handle all records.</p>
<p>A medium index column may not handle all records at the following
cases:</p>
<blockquote>
<div><ul class="simple">
<li><p>Index target is one text family (<code class="docutils literal notranslate"><span class="pre">ShortText</span></code>, <code class="docutils literal notranslate"><span class="pre">Text</span></code> or
<code class="docutils literal notranslate"><span class="pre">LongText</span></code>) scalar column</p></li>
<li><p>Index target is one vector column</p></li>
<li><p>Index targets are multiple columns</p></li>
<li><p>Index table has tokenizer</p></li>
</ul>
</div></blockquote>
<p>You need to add <code class="docutils literal notranslate"><span class="pre">INDEX_MEDIUM</span></code> to the <code class="docutils literal notranslate"><span class="pre">flags</span></code> parameter such as
<code class="docutils literal notranslate"><span class="pre">COLUMN_INDEX|INDEX_MEDIUM</span></code> to create a medium index column.</p>
<p>You can use a medium index column for an index column of the <code class="docutils literal notranslate"><span class="pre">age</span></code>
column of the <code class="docutils literal notranslate"><span class="pre">People</span></code> table safely. Because it’s one scalar column
with <code class="docutils literal notranslate"><span class="pre">UInt8</span></code> type.</p>
<p>Here is an example to create a medium index column:</p>
<p>Execution example:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>column_create \
  --table Ages \
  --name people_age_medium_index \
  --flags COLUMN_INDEX|INDEX_MEDIUM \
  --type People \
  --source age
# [[0, 1337566253.89858, 0.000355720520019531], true]
</pre></div>
</div>
</div>
<div class="section" id="create-a-large-index-column">
<span id="column-create-index-large"></span><h3><span class="section-number">7.3.11.3.10. </span>Create a large index column<a class="headerlink" href="#create-a-large-index-column" title="Permalink to this headline">¶</a></h3>
<p>If you know index target data are large, you need to use large index
column. It uses increases memory usage for the index column but it can
accept more data. Memory usage is 2 times larger than the default
index column.</p>
<p>How many data are large? It depends on data.</p>
<p>If index target is only one scalar column, it’s not large data.</p>
<p>Large data must have many records (normally at least 10 millions
records) and at least one of the following features:</p>
<blockquote>
<div><ul class="simple">
<li><p>Index targets are multiple columns</p></li>
<li><p>Index table has tokenizer</p></li>
</ul>
</div></blockquote>
<p>You need to add <code class="docutils literal notranslate"><span class="pre">INDEX_LARGE</span></code> to the <code class="docutils literal notranslate"><span class="pre">flags</span></code> parameter such as
<code class="docutils literal notranslate"><span class="pre">COLUMN_INDEX|INDEX_LARGE</span></code> to create a large index column.</p>
<p>You can use a large index column for an index column of the <code class="docutils literal notranslate"><span class="pre">_key</span></code>
of the <code class="docutils literal notranslate"><span class="pre">People</span></code> table and the <code class="docutils literal notranslate"><span class="pre">role</span></code> column of the <code class="docutils literal notranslate"><span class="pre">People</span></code>
table.</p>
<p>Here is an example to create a large index column:</p>
<p>Execution example:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>column_create \
  --table Terms \
  --name people_roles_large_index \
  --flags COLUMN_INDEX|WITH_POSITION|WITH_SECTION|INDEX_LARGE \
  --type People \
  --source roles
# [[0, 1337566253.89858, 0.000355720520019531], true]
</pre></div>
</div>
</div>
</div>
<div class="section" id="parameters">
<h2><span class="section-number">7.3.11.4. </span>Parameters<a class="headerlink" href="#parameters" title="Permalink to this headline">¶</a></h2>
<p>This section describes all parameters.</p>
<div class="section" id="required-parameters">
<h3><span class="section-number">7.3.11.4.1. </span>Required parameters<a class="headerlink" href="#required-parameters" title="Permalink to this headline">¶</a></h3>
<p>There are some required parameters.</p>
<div class="section" id="table">
<span id="column-create-table"></span><h4><span class="section-number">7.3.11.4.1.1. </span><code class="docutils literal notranslate"><span class="pre">table</span></code><a class="headerlink" href="#table" title="Permalink to this headline">¶</a></h4>
<p>Specifies an existing table name for the new column.</p>
</div>
<div class="section" id="name">
<span id="column-create-name"></span><h4><span class="section-number">7.3.11.4.1.2. </span><code class="docutils literal notranslate"><span class="pre">name</span></code><a class="headerlink" href="#name" title="Permalink to this headline">¶</a></h4>
<p>Specifies the column name to be created.</p>
<p>The column name must be unique in the same table.</p>
<p>Here are available characters:</p>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">0</span></code> .. <code class="docutils literal notranslate"><span class="pre">9</span></code> (digit)</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">a</span></code> .. <code class="docutils literal notranslate"><span class="pre">z</span></code> (alphabet, lower case)</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">A</span></code> .. <code class="docutils literal notranslate"><span class="pre">Z</span></code> (alphabet, upper case)</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">#</span></code> (hash)</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">&#64;</span></code> (at mark)</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">-</span></code> (hyphen)</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">_</span></code> (underscore) (NOTE: Underscore can’t be used as the first
character.)</p></li>
</ul>
<p>You need to create a name with one or more the above characters. Note
that you can’t use <code class="docutils literal notranslate"><span class="pre">_</span></code> as the first character such as <code class="docutils literal notranslate"><span class="pre">_name</span></code>.</p>
</div>
<div class="section" id="flags">
<span id="column-create-flags"></span><h4><span class="section-number">7.3.11.4.1.3. </span><code class="docutils literal notranslate"><span class="pre">flags</span></code><a class="headerlink" href="#flags" title="Permalink to this headline">¶</a></h4>
<p>Specifies the column type and column customize options.</p>
<p>Here are available flags:</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>Flag</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">COLUMN_SCALAR</span></code></p></td>
<td><p>Scalar column. It can store one value. See also
<a class="reference internal" href="../columns/scalar.html"><span class="doc">Scalar column</span></a> or
<a class="reference internal" href="#column-create-scalar"><span class="std std-ref">Create a scalar column</span></a>.</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">COLUMN_VECTOR</span></code></p></td>
<td><p>Vector column. It can store multiple values. See also
<a class="reference internal" href="../columns/vector.html"><span class="doc">Vector column</span></a> or
<a class="reference internal" href="#column-create-vector"><span class="std std-ref">Create a vector column</span></a>.</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">COLUMN_INDEX</span></code></p></td>
<td><p>Index column. It stores data for fast search. See also
<a class="reference internal" href="../columns/index.html"><span class="doc">Index column</span></a> or
<a class="reference internal" href="#column-create-index"><span class="std std-ref">Create an index column</span></a>.</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">COMPRESS_ZLIB</span></code></p></td>
<td><p>It enables column value compression by zlib. You need Groonga
that enables zlib support.</p>
<p>Compression by zlib is higher space efficiency than compression
by LZ4. But compression by zlib is slower than compression by
LZ4.</p>
<p>This flag is available only for <code class="docutils literal notranslate"><span class="pre">COLUMN_SCALAR</span></code> and
<code class="docutils literal notranslate"><span class="pre">COLUMN_VECTOR</span></code>.</p>
</td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">COMPRESS_LZ4</span></code></p></td>
<td><p>It enables column value compression by LZ4. You need Groonga
that enables LZ4 support.</p>
<p>Compression by LZ4 is faster than compression by zlib. But
compression by LZ4 is lower space efficiency than compression
by zlib.</p>
<p>This flag is available only for <code class="docutils literal notranslate"><span class="pre">COLUMN_SCALAR</span></code> and
<code class="docutils literal notranslate"><span class="pre">COLUMN_VECTOR</span></code>.</p>
</td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">COMPRESS_ZSTD</span></code></p></td>
<td><p>It enables column value compression by Zstandard. You need
Groonga that enables Zstandard support.</p>
<p>Compression by Zstandard is faster than compression by zlib and
the same space efficiency as zlib.</p>
<p>This flag is available only for <code class="docutils literal notranslate"><span class="pre">COLUMN_SCALAR</span></code> and
<code class="docutils literal notranslate"><span class="pre">COLUMN_VECTOR</span></code>.</p>
</td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">WITH_SECTION</span></code></p></td>
<td><p>It enables section support to index column.</p>
<p>If section support is enabled, you can support multiple
documents in the same index column.</p>
<p>You must specify this flag to create a multiple columns index
column. See also <a class="reference internal" href="#column-create-index-multiple-columns"><span class="std std-ref">Create a multiple columns index column</span></a> for
details.</p>
<p>Section support requires additional spaces. If you don’t need
section support, you should not enable section support.</p>
<p>This flag is available only for <code class="docutils literal notranslate"><span class="pre">COLUMN_INDEX</span></code>.</p>
</td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">WITH_WEIGHT</span></code></p></td>
<td><p>It enables weight support to vector column or index column.</p>
<p>If weight support is enabled for vector column, you can add
weight for each element. If weight support is enabled for index
column, you can add weight for each posting. They are useful to
compute suitable search score.</p>
<p>You must specify this flag to use <a class="reference internal" href="select.html#select-adjuster"><span class="std std-ref">adjuster</span></a>. See
also <a class="reference internal" href="#column-create-vector-weight"><span class="std std-ref">Create a weight vector column</span></a> for details.</p>
<p>Weight support requires additional spaces. If you don’t need
weight support, you should not enable weight support.</p>
<p>This flag is available only for <code class="docutils literal notranslate"><span class="pre">COLUMN_VECTOR</span></code> or
<code class="docutils literal notranslate"><span class="pre">COLUMN_INDEX</span></code>.</p>
</td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">WITH_POSITION</span></code></p></td>
<td><p>It enables position support to index column. It means that the
index column is full inverted index. (Index column is
implemented as inverted index.)</p>
<p>If position support is enabled, you can add position in the
document for each posting. It’s required for phrase search. It
means that index column for full text search must enable
position support because most full text search uses phrase
search.</p>
<p>You must specify this flag to create a full text search index
column. See also <a class="reference internal" href="#column-create-index-full-text-search"><span class="std std-ref">Create an index column for full text search</span></a> for
details.</p>
<p>Position support requires additional spaces. If you don’t need
position support, you should not enable position support.</p>
<p>This flag is available only for <code class="docutils literal notranslate"><span class="pre">COLUMN_INDEX</span></code>.</p>
</td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">INDEX_SMALL</span></code></p></td>
<td><div class="versionadded">
<p><span class="versionmodified added">New in version 6.0.8.</span></p>
</div>
<p>It requires to create a small index column.</p>
<p>If index target data are small, small index column is enough.
Small index column uses fewer memory than a normal index column
or a medium index column. See also
<a class="reference internal" href="#column-create-index-small"><span class="std std-ref">Create a small index column</span></a> for knowing what are “small
data” and how to use this flag.</p>
<p>This flag is available only for <code class="docutils literal notranslate"><span class="pre">COLUMN_INDEX</span></code>.</p>
</td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">INDEX_MEDIUM</span></code></p></td>
<td><div class="versionadded">
<p><span class="versionmodified added">New in version 6.0.8.</span></p>
</div>
<p>It requires to create a medium index column.</p>
<p>If index target data are medium, medium index column is enough.
Medium index column uses fewer memory than a normal index
column. See also <a class="reference internal" href="#column-create-index-medium"><span class="std std-ref">Create a medium index column</span></a> for knowing
what are “medium data” and how to use this flag.</p>
<p>This flag is available only for <code class="docutils literal notranslate"><span class="pre">COLUMN_INDEX</span></code>.</p>
</td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">INDEX_LARGE</span></code></p></td>
<td><div class="versionadded">
<p><span class="versionmodified added">New in version 9.0.2.</span></p>
</div>
<p>It requires to create a large index column.</p>
<p>If index target data are large, you need to use large index
column. Large index column uses more memory than a normal index
column but accepts more data than a normal index column. See
also <a class="reference internal" href="#column-create-index-large"><span class="std std-ref">Create a large index column</span></a> for knowing what are
“large data” and how to use this flag.</p>
<p>This flag is available only for <code class="docutils literal notranslate"><span class="pre">COLUMN_INDEX</span></code>.</p>
</td>
</tr>
</tbody>
</table>
<p>You must specify one of <code class="docutils literal notranslate"><span class="pre">COLUMN_${TYPE}</span></code> flags. You can’t specify
two or more <code class="docutils literal notranslate"><span class="pre">COLUMN_${TYPE}</span></code> flags. For example,
<code class="docutils literal notranslate"><span class="pre">COLUMN_SCALAR|COLUMN_VECTOR</span></code> is invalid.</p>
<p>You can combine flags with <code class="docutils literal notranslate"><span class="pre">|</span></code> (vertical bar) such as
<code class="docutils literal notranslate"><span class="pre">COLUMN_INDEX|WITH_SECTION|WITH_POSITION</span></code>.</p>
</div>
<div class="section" id="type">
<span id="column-create-type"></span><h4><span class="section-number">7.3.11.4.1.4. </span><code class="docutils literal notranslate"><span class="pre">type</span></code><a class="headerlink" href="#type" title="Permalink to this headline">¶</a></h4>
<p>Specifies type of the column value.</p>
<p>If the column is scalar column or vector column, here are available
types:</p>
<blockquote>
<div><ul class="simple">
<li><p>Builtin types described in <a class="reference internal" href="../types.html"><span class="doc">Data types</span></a></p></li>
<li><p>Tables defined by users</p></li>
</ul>
</div></blockquote>
<p>If the column is index column, here are available types:</p>
<blockquote>
<div><ul class="simple">
<li><p>Tables defined by users</p></li>
</ul>
</div></blockquote>
<p>See also the followings:</p>
<blockquote>
<div><ul class="simple">
<li><p><a class="reference internal" href="#column-create-scalar"><span class="std std-ref">Create a scalar column</span></a></p></li>
<li><p><a class="reference internal" href="#column-create-vector"><span class="std std-ref">Create a vector column</span></a></p></li>
<li><p><a class="reference internal" href="#column-create-reference"><span class="std std-ref">Create a column that refers a table’s record</span></a></p></li>
<li><p><a class="reference internal" href="#column-create-index"><span class="std std-ref">Create an index column</span></a></p></li>
</ul>
</div></blockquote>
</div>
</div>
<div class="section" id="optional-parameters">
<h3><span class="section-number">7.3.11.4.2. </span>Optional parameters<a class="headerlink" href="#optional-parameters" title="Permalink to this headline">¶</a></h3>
<p>There is an optional parameter.</p>
<div class="section" id="source">
<span id="column-create-source"></span><h4><span class="section-number">7.3.11.4.2.1. </span><code class="docutils literal notranslate"><span class="pre">source</span></code><a class="headerlink" href="#source" title="Permalink to this headline">¶</a></h4>
<p>Specifies index target columns. You can specify one or more columns to
the <code class="docutils literal notranslate"><span class="pre">source</span></code> parameter.</p>
<p>This parameter is only available for index column.</p>
<p>You can only specify columns of the table specified as
<a class="reference internal" href="#column-create-type"><span class="std std-ref">type</span></a>. You can also use the <code class="docutils literal notranslate"><span class="pre">_key</span></code> pseudo column
for specifying the table key as index target.</p>
<p>If you specify multiple columns to the <code class="docutils literal notranslate"><span class="pre">source</span></code> parameter, separate
columns with <code class="docutils literal notranslate"><span class="pre">,</span></code> (comma) such as <code class="docutils literal notranslate"><span class="pre">_key,roles</span></code>.</p>
</div>
<div class="section" id="path">
<h4><span class="section-number">7.3.11.4.2.2. </span><code class="docutils literal notranslate"><span class="pre">path</span></code><a class="headerlink" href="#path" title="Permalink to this headline">¶</a></h4>
<div class="versionadded">
<p><span class="versionmodified added">New in version 10.0.7.</span></p>
</div>
<p>Specifies a path for storing a column.</p>
<p>This option is useful if you want to store a column that
you often use to fast storage (e.g. SSD) and store it that you don’t often
use to slow storage (e.g. HDD).</p>
<p>You can use a relative path or an absolute path in this option.
If you specify a relative path, it is resolved from the current directory for the <code class="docutils literal notranslate"><span class="pre">groonga</span></code> process.</p>
<p>The default value is none.</p>
</div>
</div>
</div>
<div class="section" id="return-value">
<h2><span class="section-number">7.3.11.5. </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">column_create</span></code> returns <code class="docutils literal notranslate"><span class="pre">true</span></code> as body on success such as:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>[HEADER, true]
</pre></div>
</div>
<p>If <code class="docutils literal notranslate"><span class="pre">column_create</span></code> fails, <code class="docutils literal notranslate"><span class="pre">column_create</span></code> returns <code class="docutils literal notranslate"><span class="pre">false</span></code> as
body:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>[HEADER, false]
</pre></div>
</div>
<p>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>
</div>
<div class="section" id="see-also">
<h2><span class="section-number">7.3.11.6. </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="../column.html"><span class="doc">Column</span></a></p></li>
<li><p><a class="reference internal" href="table_create.html"><span class="doc">table_create</span></a></p></li>
<li><p><a class="reference internal" href="../command/output_format.html"><span class="doc">Output format</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.3.11. <code class="docutils literal notranslate"><span class="pre">column_create</span></code></a><ul>
<li><a class="reference internal" href="#summary">7.3.11.1. Summary</a></li>
<li><a class="reference internal" href="#syntax">7.3.11.2. Syntax</a></li>
<li><a class="reference internal" href="#usage">7.3.11.3. Usage</a><ul>
<li><a class="reference internal" href="#create-a-scalar-column">7.3.11.3.1. Create a scalar column</a></li>
<li><a class="reference internal" href="#create-a-vector-column">7.3.11.3.2. Create a vector column</a></li>
<li><a class="reference internal" href="#create-a-weight-vector-column">7.3.11.3.3. Create a weight vector column</a></li>
<li><a class="reference internal" href="#create-a-column-that-refers-a-table-s-record">7.3.11.3.4. Create a column that refers a table’s record</a></li>
<li><a class="reference internal" href="#create-an-index-column">7.3.11.3.5. Create an index column</a></li>
<li><a class="reference internal" href="#create-an-index-column-for-full-text-search">7.3.11.3.6. Create an index column for full text search</a></li>
<li><a class="reference internal" href="#create-a-multiple-columns-index-column">7.3.11.3.7. Create a multiple columns index column</a></li>
<li><a class="reference internal" href="#create-a-small-index-column">7.3.11.3.8. Create a small index column</a></li>
<li><a class="reference internal" href="#create-a-medium-index-column">7.3.11.3.9. Create a medium index column</a></li>
<li><a class="reference internal" href="#create-a-large-index-column">7.3.11.3.10. Create a large index column</a></li>
</ul>
</li>
<li><a class="reference internal" href="#parameters">7.3.11.4. Parameters</a><ul>
<li><a class="reference internal" href="#required-parameters">7.3.11.4.1. Required parameters</a><ul>
<li><a class="reference internal" href="#table">7.3.11.4.1.1. <code class="docutils literal notranslate"><span class="pre">table</span></code></a></li>
<li><a class="reference internal" href="#name">7.3.11.4.1.2. <code class="docutils literal notranslate"><span class="pre">name</span></code></a></li>
<li><a class="reference internal" href="#flags">7.3.11.4.1.3. <code class="docutils literal notranslate"><span class="pre">flags</span></code></a></li>
<li><a class="reference internal" href="#type">7.3.11.4.1.4. <code class="docutils literal notranslate"><span class="pre">type</span></code></a></li>
</ul>
</li>
<li><a class="reference internal" href="#optional-parameters">7.3.11.4.2. Optional parameters</a><ul>
<li><a class="reference internal" href="#source">7.3.11.4.2.1. <code class="docutils literal notranslate"><span class="pre">source</span></code></a></li>
<li><a class="reference internal" href="#path">7.3.11.4.2.2. <code class="docutils literal notranslate"><span class="pre">path</span></code></a></li>
</ul>
</li>
</ul>
</li>
<li><a class="reference internal" href="#return-value">7.3.11.5. Return value</a></li>
<li><a class="reference internal" href="#see-also">7.3.11.6. See also</a></li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="column_copy.html"
                        title="previous chapter"><span class="section-number">7.3.10. </span><code class="docutils literal notranslate"><span class="pre">column_copy</span></code></a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="column_list.html"
                        title="next chapter"><span class="section-number">7.3.12. </span><code class="docutils literal notranslate"><span class="pre">column_list</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="column_list.html" title="7.3.12. column_list"
             >next</a> |</li>
        <li class="right" >
          <a href="column_copy.html" title="7.3.10. column_copy"
             >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.11. </span><code class="docutils literal notranslate"><span class="pre">column_create</span></code></a></li> 
      </ul>
    </div>
    <div class="footer" role="contentinfo">
        &#169; Copyright 2009-2021, Brazil, Inc.
    </div>
  </body>
</html>