File: micro_blog.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 (1003 lines) | stat: -rw-r--r-- 40,252 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


<!DOCTYPE html>

<html lang="en">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>4.10. Let’s create micro-blog &#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="4.11. Query expansion" href="query_expansion.html" />
    <link rel="prev" title="4.9. Additional information about lexicon for full text search" href="lexicon.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/tutorial/micro_blog.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="query_expansion.html" title="4.11. Query expansion"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="lexicon.html" title="4.9. Additional information about lexicon for full text search"
             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="../tutorial.html" accesskey="U"><span class="section-number">4. </span>Tutorial</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href=""><span class="section-number">4.10. </span>Let’s create micro-blog</a></li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body" role="main">
            
  <div class="section" id="let-s-create-micro-blog">
<h1><span class="section-number">4.10. </span>Let’s create micro-blog<a class="headerlink" href="#let-s-create-micro-blog" title="Permalink to this headline">¶</a></h1>
<p>Let’s create micro-blog with full text search by Groonga.
Micro-blog is one of the broadcast medium in the forms of blog. It is mainly used to post small messages like a Twitter.</p>
<div class="section" id="create-a-table">
<h2><span class="section-number">4.10.1. </span>Create a table<a class="headerlink" href="#create-a-table" title="Permalink to this headline">¶</a></h2>
<p>Let’s create table.</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>table_create --name Users --flags TABLE_HASH_KEY --key_type ShortText
table_create --name Comments --flags TABLE_HASH_KEY --key_type ShortText
table_create --name HashTags --flags TABLE_HASH_KEY --key_type ShortText
table_create --name Bigram --flags TABLE_PAT_KEY --key_type ShortText --default_tokenizer TokenBigram --normalizer NormalizerAuto
table_create --name GeoIndex --flags TABLE_PAT_KEY --key_type WGS84GeoPoint

column_create --table Users --name name --flags COLUMN_SCALAR --type ShortText
column_create --table Users --name follower --flags COLUMN_VECTOR --type Users
column_create --table Users --name favorites --flags COLUMN_VECTOR --type Comments
column_create --table Users --name location --flags COLUMN_SCALAR --type WGS84GeoPoint
column_create --table Users --name location_str --flags COLUMN_SCALAR --type ShortText
column_create --table Users --name description --flags COLUMN_SCALAR --type ShortText
column_create --table Users --name followee --flags COLUMN_INDEX --type Users --source follower

column_create --table Comments --name comment --flags COLUMN_SCALAR --type ShortText
column_create --table Comments --name last_modified --flags COLUMN_SCALAR --type Time
column_create --table Comments --name replied_to --flags COLUMN_SCALAR --type Comments
column_create --table Comments --name replied_users --flags COLUMN_VECTOR --type Users
column_create --table Comments --name hash_tags --flags COLUMN_VECTOR --type HashTags
column_create --table Comments --name location --flags COLUMN_SCALAR --type WGS84GeoPoint
column_create --table Comments --name posted_by --flags COLUMN_SCALAR --type Users
column_create --table Comments --name favorited_by --flags COLUMN_INDEX --type Users --source favorites

column_create --table HashTags --name hash_index --flags COLUMN_INDEX --type Comments --source hash_tags

column_create --table Bigram --name users_index --flags COLUMN_INDEX|WITH_POSITION|WITH_SECTION --type Users --source name,location_str,description
column_create --table Bigram --name comment_index --flags COLUMN_INDEX|WITH_POSITION --type Comments --source comment

column_create --table GeoIndex --name users_location --type Users --flags COLUMN_INDEX --source location
column_create --table GeoIndex --name comments_location --type Comments --flags COLUMN_INDEX --source location
</pre></div>
</div>
<div class="section" id="users-table">
<h3><span class="section-number">4.10.1.1. </span>Users table<a class="headerlink" href="#users-table" title="Permalink to this headline">¶</a></h3>
<p>This is the table which stores user information.
It stores name of user, profile, list of follower and so on.</p>
<dl class="simple">
<dt><code class="docutils literal notranslate"><span class="pre">_key</span></code></dt><dd><p>User ID</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">name</span></code></dt><dd><p>User name</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">follower</span></code></dt><dd><p>List of following users</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">favorites</span></code></dt><dd><p>List of favorite comments</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">location</span></code></dt><dd><p>Current location of user (geolocation)</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">location_str</span></code></dt><dd><p>Current location of user (string)</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">description</span></code></dt><dd><p>User profile</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">followee</span></code></dt><dd><p>Indexes for <code class="docutils literal notranslate"><span class="pre">follower</span></code> column in <code class="docutils literal notranslate"><span class="pre">Users</span></code> table.
With this indexes, you can search users who follows the person.</p>
</dd>
</dl>
</div>
<div class="section" id="comments-table">
<h3><span class="section-number">4.10.1.2. </span>Comments table<a class="headerlink" href="#comments-table" title="Permalink to this headline">¶</a></h3>
<p>This is the table which stores comments and its metadata.
It stores content of comment, posted date, comment which reply to, and so on.</p>
<dl class="simple">
<dt><code class="docutils literal notranslate"><span class="pre">_key</span></code></dt><dd><p>Comment ID</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">comment</span></code></dt><dd><p>Content of comment</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">last_modified</span></code></dt><dd><p>Posted date</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">replied_to</span></code></dt><dd><p>Comment which you reply to someone</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">replied_users</span></code></dt><dd><p>List of users who you reply to</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">hash_tags</span></code></dt><dd><p>List of hash tags about comment</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">location</span></code></dt><dd><p>Posted place (for geolocation)</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">posted_by</span></code></dt><dd><p>Person who write comment</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">favorited_by</span></code></dt><dd><p>Indexes for <code class="docutils literal notranslate"><span class="pre">favorites</span></code> column in <code class="docutils literal notranslate"><span class="pre">Users</span></code> table.
With this indexes, you can search the person who mark comment as favorite one.</p>
</dd>
</dl>
</div>
<div class="section" id="hashtags-table">
<h3><span class="section-number">4.10.1.3. </span>HashTags table<a class="headerlink" href="#hashtags-table" title="Permalink to this headline">¶</a></h3>
<p>This is the table which stores hash tags for comments.</p>
<dl class="simple">
<dt><code class="docutils literal notranslate"><span class="pre">_key</span></code></dt><dd><p>Hash tag</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">hash_index</span></code></dt><dd><p>Indexes for <code class="docutils literal notranslate"><span class="pre">Comments.hash_tags</span></code>.
With this indexes, you can search list of comments with specified hash tags.</p>
</dd>
</dl>
</div>
<div class="section" id="bigram-table">
<h3><span class="section-number">4.10.1.4. </span>Bigram table<a class="headerlink" href="#bigram-table" title="Permalink to this headline">¶</a></h3>
<p>This is the table which stores indexes for full text search by user information or comments.</p>
<dl class="simple">
<dt><code class="docutils literal notranslate"><span class="pre">_key</span></code></dt><dd><p>Word</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">users_index</span></code></dt><dd><p>Indexes of user information.
This column contains indexes of user name (<code class="docutils literal notranslate"><span class="pre">Users.name</span></code>), current location (<code class="docutils literal notranslate"><span class="pre">Users.location_str</span></code>), profile (<code class="docutils literal notranslate"><span class="pre">Users.description</span></code>).</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">comment_index</span></code></dt><dd><p>Indexes about content of comments (<code class="docutils literal notranslate"><span class="pre">Comments.comment</span></code>).</p>
</dd>
</dl>
</div>
<div class="section" id="geoindex-table">
<h3><span class="section-number">4.10.1.5. </span>GeoIndex table<a class="headerlink" href="#geoindex-table" title="Permalink to this headline">¶</a></h3>
<p>This is the table which stores indexes of location column to search geo location effectively.</p>
<dl class="simple">
<dt><code class="docutils literal notranslate"><span class="pre">users_location</span></code></dt><dd><p>Indexes of location column for Users table</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">comments_location</span></code></dt><dd><p>Indexes of location column for Comments table</p>
</dd>
</dl>
</div>
</div>
<div class="section" id="loading-data">
<h2><span class="section-number">4.10.2. </span>Loading data<a class="headerlink" href="#loading-data" title="Permalink to this headline">¶</a></h2>
<p>Then, load example data.</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>load --table Users
[
  {
    &quot;_key&quot;: &quot;alice&quot;,
    &quot;name&quot;: &quot;Alice&quot;,
    &quot;follower&quot;: [&quot;bob&quot;],
    &quot;favorites&quot;: [],
    &quot;location&quot;: &quot;152489000x-255829000&quot;,
    &quot;location_str&quot;: &quot;Boston, Massachusetts&quot;,
    &quot;description&quot;: &quot;Groonga developer&quot;
  },
  {
    &quot;_key&quot;: &quot;bob&quot;,
    &quot;name&quot;: &quot;Bob&quot;,
    &quot;follower&quot;: [&quot;alice&quot;,&quot;charlie&quot;],
    &quot;favorites&quot;: [&quot;alice:1&quot;,&quot;charlie:1&quot;],
    &quot;location&quot;: &quot;146249000x-266228000&quot;,
    &quot;location_str&quot;: &quot;Brooklyn, New York City&quot;,
    &quot;description&quot;: &quot;&quot;
  },
  {
    &quot;_key&quot;: &quot;charlie&quot;,
    &quot;name&quot;: &quot;Charlie&quot;,
    &quot;follower&quot;: [&quot;alice&quot;,&quot;bob&quot;],
    &quot;favorites&quot;: [&quot;alice:1&quot;,&quot;bob:1&quot;],
    &quot;location&quot;: &quot;146607190x-267021260&quot;,
    &quot;location_str&quot;: &quot;Newark, New Jersey&quot;,
    &quot;description&quot;: &quot;Hmm,Hmm&quot;
  }
]

load --table Comments
[
  {
    &quot;_key&quot;: &quot;alice:1&quot;,
    &quot;comment&quot;: &quot;I&#39;ve created micro-blog!&quot;,
    &quot;last_modified&quot;: &quot;2010/03/17 12:05:00&quot;,
    &quot;posted_by&quot;: &quot;alice&quot;,
  },
  {
    &quot;_key&quot;: &quot;bob:1&quot;,
    &quot;comment&quot;: &quot;First post. test,test...&quot;,
    &quot;last_modified&quot;: &quot;2010/03/17 12:00:00&quot;,
    &quot;posted_by&quot;: &quot;bob&quot;,
  },
  {
    &quot;_key&quot;: &quot;alice:2&quot;,
    &quot;comment&quot;: &quot;@bob Welcome!!!&quot;,
    &quot;last_modified&quot;: &quot;2010/03/17 12:05:00&quot;,
    &quot;replied_to&quot;: &quot;bob:1&quot;,
    &quot;replied_users&quot;: [&quot;bob&quot;],
    &quot;posted_by&quot;: &quot;alice&quot;,
  },
  {
    &quot;_key&quot;: &quot;bob:2&quot;,
    &quot;comment&quot;: &quot;@alice Thanks!&quot;,
    &quot;last_modified&quot;: &quot;2010/03/17 13:00:00&quot;,
    &quot;replied_to&quot;: &quot;alice:2&quot;,
    &quot;replied_users&quot;: [&quot;alice&quot;],
    &quot;posted_by&quot;: &quot;bob&quot;,
  },
  {
    &quot;_key&quot;: &quot;bob:3&quot;,
    &quot;comment&quot;: &quot;I&#39;ve just used &#39;Try-Groonga&#39; now! #groonga&quot;,
    &quot;last_modified&quot;: &quot;2010/03/17 14:00:00&quot;,
    &quot;hash_tags&quot;: [&quot;groonga&quot;],
    &quot;location&quot;: &quot;146566000x-266422000&quot;,
    &quot;posted_by&quot;: &quot;bob&quot;,
  },
  {
    &quot;_key&quot;: &quot;bob:4&quot;,
    &quot;comment&quot;: &quot;I&#39;m come at city of New York for development camp! #groonga #travel&quot;,
    &quot;last_modified&quot;: &quot;2010/03/17 14:05:00&quot;,
    &quot;hash_tags&quot;: [&quot;groonga&quot;, &quot;travel&quot;],
    &quot;location&quot;: &quot;146566000x-266422000&quot;,
    &quot;posted_by&quot;: &quot;bob&quot;,
  },
  {
    &quot;_key&quot;: &quot;charlie:1&quot;,
    &quot;comment&quot;: &quot;@alice @bob I&#39;ve tried to register!&quot;,
    &quot;last_modified&quot;: &quot;2010/03/17 15:00:00&quot;,
    &quot;replied_users&quot;: [&quot;alice&quot;, &quot;bob&quot;],
    &quot;location&quot;: &quot;146607190x-267021260&quot;,
    &quot;posted_by&quot;: &quot;charlie&quot;,
  }
  {
    &quot;_key&quot;: &quot;charlie:2&quot;,
    &quot;comment&quot;: &quot;I&#39;m at the Museum of Modern Art in NY now!&quot;,
    &quot;last_modified&quot;: &quot;2010/03/17 15:05:00&quot;,
    &quot;location&quot;: &quot;146741340x-266319590&quot;,
    &quot;posted_by&quot;: &quot;charlie&quot;,
  }
]
</pre></div>
</div>
<p><code class="docutils literal notranslate"><span class="pre">follower</span></code> column and <code class="docutils literal notranslate"><span class="pre">favorites</span></code> column in <code class="docutils literal notranslate"><span class="pre">Users</span></code> table and <code class="docutils literal notranslate"><span class="pre">replied_users</span></code> column in <code class="docutils literal notranslate"><span class="pre">Comments</span></code> table are vector column, so specify the value as an array.</p>
<p><code class="docutils literal notranslate"><span class="pre">location</span></code> column in <code class="docutils literal notranslate"><span class="pre">Users</span></code> table, <code class="docutils literal notranslate"><span class="pre">location</span></code> column in <code class="docutils literal notranslate"><span class="pre">Comments</span></code> table use GeoPoint type. This type accepts “[latitude]x[longitude]”.</p>
<p><code class="docutils literal notranslate"><span class="pre">last_modified</span></code> column in <code class="docutils literal notranslate"><span class="pre">Comments</span></code> table use Time type.</p>
<p>There are two way to specify the value.
First, specify epoch (seconds since Jan, 1, 1970 AM 00:00:00) directly. In this case, you can specify micro seconds as fractional part.
The value is converted from factional part to the time which is micro seconds based one when data is loaded.
The second, specify the timestamp as string in following format: “(YEAR)/(MONTH)/(DAY) (HOUR):(MINUTE):(SECOND)”. In this way, the string is casted to proper micro seconds
when data is loaded.</p>
</div>
<div class="section" id="search">
<h2><span class="section-number">4.10.3. </span>Search<a class="headerlink" href="#search" title="Permalink to this headline">¶</a></h2>
<p>Let’s search micro-blog.</p>
<div class="section" id="search-users-by-keyword">
<h3><span class="section-number">4.10.3.1. </span>Search users by keyword<a class="headerlink" href="#search-users-by-keyword" title="Permalink to this headline">¶</a></h3>
<p>In this section, we search micro-blog against multiple column by keyword.
See <a class="reference internal" href="match_columns.html"><span class="doc">match_columns parameter</span></a> to search multiple column at once.</p>
<p>Let’s search user from micro-blog’s user name, location, description entries.</p>
<p>Execution example:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>select --table Users --match_columns name,location_str,description --query &quot;New York&quot; --output_columns _key,name
# [
#   [
#     0,
#     1337566253.89858,
#     0.000355720520019531
#   ],
#   [
#     [
#       [
#         1
#       ],
#       [
#         [
#           &quot;_key&quot;,
#           &quot;ShortText&quot;
#         ],
#         [
#           &quot;name&quot;,
#           &quot;ShortText&quot;
#         ]
#       ],
#       [
#         &quot;bob&quot;,
#         &quot;Bob&quot;
#       ]
#     ]
#   ]
# ]
</pre></div>
</div>
<p>By using “New York” as searching keyword for user, “Bob” who lives in “New York” is listed in search result.</p>
</div>
<div class="section" id="search-users-by-geolocation-data-geopoint">
<h3><span class="section-number">4.10.3.2. </span>Search users by geolocation data (GeoPoint)<a class="headerlink" href="#search-users-by-geolocation-data-geopoint" title="Permalink to this headline">¶</a></h3>
<p>In this section, we search users by column data which use type of GeoPoint.
See <a class="reference internal" href="search.html"><span class="doc">Various search conditions</span></a> about GeoPoint column.</p>
<p>Following example searches users who live in within 20km from specified location.</p>
<p>Execution example:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>select --table Users --filter &#39;geo_in_circle(location,&quot;146710080x-266315480&quot;,20000)&#39; --output_columns _key,name
# [
#   [
#     0,
#     1337566253.89858,
#     0.000355720520019531
#   ],
#   [
#     [
#       [
#         2
#       ],
#       [
#         [
#           &quot;_key&quot;,
#           &quot;ShortText&quot;
#         ],
#         [
#           &quot;name&quot;,
#           &quot;ShortText&quot;
#         ]
#       ],
#       [
#         &quot;charlie&quot;,
#         &quot;Charlie&quot;
#       ],
#       [
#         &quot;bob&quot;,
#         &quot;Bob&quot;
#       ]
#     ]
#   ]
# ]
</pre></div>
</div>
<p>It shows that “Bob” and “Charlie” lives in within 20 km from station of “Grand Central Terminal”.</p>
</div>
<div class="section" id="search-users-who-follows-specific-user">
<h3><span class="section-number">4.10.3.3. </span>Search users who follows specific user<a class="headerlink" href="#search-users-who-follows-specific-user" title="Permalink to this headline">¶</a></h3>
<p>In this section, we do reverse resolution of reference relationships which is described at <a class="reference internal" href="index.html"><span class="doc">Tag search and reverse resolution of reference relationships</span></a>.</p>
<p>Following examples shows reverse resolution about <code class="docutils literal notranslate"><span class="pre">follower</span></code> column of <code class="docutils literal notranslate"><span class="pre">Users</span></code> table.</p>
<p>Execution example:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>select --table Users --query follower:@bob --output_columns _key,name
# [
#   [
#     0,
#     1337566253.89858,
#     0.000355720520019531
#   ],
#   [
#     [
#       [
#         2
#       ],
#       [
#         [
#           &quot;_key&quot;,
#           &quot;ShortText&quot;
#         ],
#         [
#           &quot;name&quot;,
#           &quot;ShortText&quot;
#         ]
#       ],
#       [
#         &quot;alice&quot;,
#         &quot;Alice&quot;
#       ],
#       [
#         &quot;charlie&quot;,
#         &quot;Charlie&quot;
#       ]
#     ]
#   ]
# ]
</pre></div>
</div>
<p>It shows that “Alice” and “Charlie” follows “Bob”.</p>
</div>
<div class="section" id="search-comments-by-using-the-value-of-geopoint-type">
<h3><span class="section-number">4.10.3.4. </span>Search comments by using the value of GeoPoint type<a class="headerlink" href="#search-comments-by-using-the-value-of-geopoint-type" title="Permalink to this headline">¶</a></h3>
<p>In this section, we search comments which are written within specific location.</p>
<p>Then, we also use drill down which is described at <a class="reference internal" href="drilldown.html"><span class="doc">Drilldown</span></a>.
Following example shows how to drill down against search results.
As a result, we get the value of count which is grouped by user, and hash tags respectively.</p>
<p>Execution example:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>select --table Comments --filter &#39;geo_in_circle(location,&quot;146867000x-266280000&quot;,20000)&#39; --output_columns posted_by.name,comment --drilldown hash_tags,posted_by
# [
#   [
#     0,
#     1337566253.89858,
#     0.000355720520019531
#   ],
#   [
#     [
#       [
#         4
#       ],
#       [
#         [
#           &quot;posted_by.name&quot;,
#           &quot;ShortText&quot;
#         ],
#         [
#           &quot;comment&quot;,
#           &quot;ShortText&quot;
#         ]
#       ],
#       [
#         &quot;Charlie&quot;,
#         &quot;I&#39;m at the Museum of Modern Art in NY now!&quot;
#       ],
#       [
#         &quot;Bob&quot;,
#         &quot;I&#39;ve just used &#39;Try-Groonga&#39; now! #groonga&quot;
#       ],
#       [
#         &quot;Bob&quot;,
#         &quot;I&#39;m come at city of New York for development camp! #groonga #travel&quot;
#       ],
#       [
#         &quot;Charlie&quot;,
#         &quot;@alice @bob I&#39;ve tried to register!&quot;
#       ]
#     ],
#     [
#       [
#         2
#       ],
#       [
#         [
#           &quot;_key&quot;,
#           &quot;ShortText&quot;
#         ],
#         [
#           &quot;_nsubrecs&quot;,
#           &quot;Int32&quot;
#         ]
#       ],
#       [
#         &quot;groonga&quot;,
#         2
#       ],
#       [
#         &quot;travel&quot;,
#         1
#       ]
#     ],
#     [
#       [
#         2
#       ],
#       [
#         [
#           &quot;_key&quot;,
#           &quot;ShortText&quot;
#         ],
#         [
#           &quot;_nsubrecs&quot;,
#           &quot;Int32&quot;
#         ]
#       ],
#       [
#         &quot;charlie&quot;,
#         2
#       ],
#       [
#         &quot;bob&quot;,
#         2
#       ]
#     ]
#   ]
# ]
</pre></div>
</div>
<p>Above query searches comments which are posted within 20 km from Central Park in city of New York.</p>
<p>As specified range is 20 km, all comments with location are collected.
You know that search results contain 2 #groonga hash tags and one #travel hash tag, and bob and charlie posted 2 comments.</p>
</div>
<div class="section" id="search-comments-by-keyword">
<h3><span class="section-number">4.10.3.5. </span>Search comments by keyword<a class="headerlink" href="#search-comments-by-keyword" title="Permalink to this headline">¶</a></h3>
<p>In this section, we search comments which contains specific keyword.
And more, Let’s calculate the value of <cite>_score</cite> which is described at <a class="reference internal" href="search.html"><span class="doc">Various search conditions</span></a>.</p>
<p>Execution example:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>select --table Comments --query comment:@Now --output_columns comment,_score
# [
#   [
#     0,
#     1337566253.89858,
#     0.000355720520019531
#   ],
#   [
#     [
#       [
#         2
#       ],
#       [
#         [
#           &quot;comment&quot;,
#           &quot;ShortText&quot;
#         ],
#         [
#           &quot;_score&quot;,
#           &quot;Int32&quot;
#         ]
#       ],
#       [
#         &quot;I&#39;ve just used &#39;Try-Groonga&#39; now! #groonga&quot;,
#         1
#       ],
#       [
#         &quot;I&#39;m at the Museum of Modern Art in NY now!&quot;,
#         1
#       ]
#     ]
#   ]
# ]
</pre></div>
</div>
<p>By using ‘Now’ as a keyword, above query returns 2 comments. It also contains count of ‘Now’ as the value of <cite>_score</cite>.</p>
</div>
<div class="section" id="search-comments-by-keyword-and-geolocation">
<h3><span class="section-number">4.10.3.6. </span>Search comments by keyword and geolocation<a class="headerlink" href="#search-comments-by-keyword-and-geolocation" title="Permalink to this headline">¶</a></h3>
<p>In this section, we search comments by specific keyword and geolocation.
By using <cite>–query</cite> and <cite>–filter</cite> option, following query returns records which are matched to both conditions.</p>
<p>Execution example:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>select --table Comments --query comment:@New --filter &#39;geo_in_circle(location,&quot;146867000x-266280000&quot;,20000)&#39; --output_columns posted_by.name,comment --drilldown hash_tags,posted_by
# [
#   [
#     0,
#     1337566253.89858,
#     0.000355720520019531
#   ],
#   [
#     [
#       [
#         1
#       ],
#       [
#         [
#           &quot;posted_by.name&quot;,
#           &quot;ShortText&quot;
#         ],
#         [
#           &quot;comment&quot;,
#           &quot;ShortText&quot;
#         ]
#       ],
#       [
#         &quot;Bob&quot;,
#         &quot;I&#39;m come at city of New York for development camp! #groonga #travel&quot;
#       ]
#     ],
#     [
#       [
#         2
#       ],
#       [
#         [
#           &quot;_key&quot;,
#           &quot;ShortText&quot;
#         ],
#         [
#           &quot;_nsubrecs&quot;,
#           &quot;Int32&quot;
#         ]
#       ],
#       [
#         &quot;groonga&quot;,
#         1
#       ],
#       [
#         &quot;travel&quot;,
#         1
#       ]
#     ],
#     [
#       [
#         1
#       ],
#       [
#         [
#           &quot;_key&quot;,
#           &quot;ShortText&quot;
#         ],
#         [
#           &quot;_nsubrecs&quot;,
#           &quot;Int32&quot;
#         ]
#       ],
#       [
#         &quot;bob&quot;,
#         1
#       ]
#     ]
#   ]
# ]
</pre></div>
</div>
<p>It returns 1 comment which meets both condition.
It also returns result of drilldown. There is 1 comment which is commented by Bob.</p>
</div>
<div class="section" id="search-comments-by-hash-tags">
<h3><span class="section-number">4.10.3.7. </span>Search comments by hash tags<a class="headerlink" href="#search-comments-by-hash-tags" title="Permalink to this headline">¶</a></h3>
<p>In this section, we search comments which contains specific hash tags.
Let’s use reverse resolution of reference relationships.</p>
<p>Execution example:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>select --table Comments --query hash_tags:@groonga --output_columns posted_by.name,comment --drilldown posted_by
# [
#   [
#     0,
#     1337566253.89858,
#     0.000355720520019531
#   ],
#   [
#     [
#       [
#         2
#       ],
#       [
#         [
#           &quot;posted_by.name&quot;,
#           &quot;ShortText&quot;
#         ],
#         [
#           &quot;comment&quot;,
#           &quot;ShortText&quot;
#         ]
#       ],
#       [
#         &quot;Bob&quot;,
#         &quot;I&#39;ve just used &#39;Try-Groonga&#39; now! #groonga&quot;
#       ],
#       [
#         &quot;Bob&quot;,
#         &quot;I&#39;m come at city of New York for development camp! #groonga #travel&quot;
#       ]
#     ],
#     [
#       [
#         1
#       ],
#       [
#         [
#           &quot;_key&quot;,
#           &quot;ShortText&quot;
#         ],
#         [
#           &quot;_nsubrecs&quot;,
#           &quot;Int32&quot;
#         ]
#       ],
#       [
#         &quot;bob&quot;,
#         2
#       ]
#     ]
#   ]
# ]
</pre></div>
</div>
<p>Above query returns 2 comments which contains #groonga hash tag.
It also returns result of drilldown grouped by person who posted it. It shows that there are 2 comments. Bob commented it.</p>
</div>
<div class="section" id="search-comments-by-user-id">
<h3><span class="section-number">4.10.3.8. </span>Search comments by user id<a class="headerlink" href="#search-comments-by-user-id" title="Permalink to this headline">¶</a></h3>
<p>In this section, we search comments which are posted by specific user.</p>
<p>Execution example:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>select --table Comments --query posted_by:bob --output_columns comment --drilldown hash_tags
# [
#   [
#     0,
#     1337566253.89858,
#     0.000355720520019531
#   ],
#   [
#     [
#       [
#         4
#       ],
#       [
#         [
#           &quot;comment&quot;,
#           &quot;ShortText&quot;
#         ]
#       ],
#       [
#         &quot;First post. test,test...&quot;
#       ],
#       [
#         &quot;@alice Thanks!&quot;
#       ],
#       [
#         &quot;I&#39;ve just used &#39;Try-Groonga&#39; now! #groonga&quot;
#       ],
#       [
#         &quot;I&#39;m come at city of New York for development camp! #groonga #travel&quot;
#       ]
#     ],
#     [
#       [
#         2
#       ],
#       [
#         [
#           &quot;_key&quot;,
#           &quot;ShortText&quot;
#         ],
#         [
#           &quot;_nsubrecs&quot;,
#           &quot;Int32&quot;
#         ]
#       ],
#       [
#         &quot;groonga&quot;,
#         2
#       ],
#       [
#         &quot;travel&quot;,
#         1
#       ]
#     ]
#   ]
# ]
</pre></div>
</div>
<p>Above query returns 4 comments which are posted by Bob.
It also returns result of drilldown by hash tags. There are 2 comments which contains #groonga, and 1 comment which contains #travel as hash tag.</p>
</div>
<div class="section" id="search-user-s-favorite-comments">
<h3><span class="section-number">4.10.3.9. </span>Search user’s favorite comments<a class="headerlink" href="#search-user-s-favorite-comments" title="Permalink to this headline">¶</a></h3>
<p>In this section, we search user’s favorite comments.</p>
<p>Execution example:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>select --table Users --query _key:bob --output_columns favorites.posted_by,favorites.comment
# [
#   [
#     0,
#     1337566253.89858,
#     0.000355720520019531
#   ],
#   [
#     [
#       [
#         1
#       ],
#       [
#         [
#           &quot;favorites.posted_by&quot;,
#           &quot;Users&quot;
#         ],
#         [
#           &quot;favorites.comment&quot;,
#           &quot;ShortText&quot;
#         ]
#       ],
#       [
#         [
#           &quot;alice&quot;,
#           &quot;charlie&quot;
#         ],
#         [
#           &quot;I&#39;ve created micro-blog!&quot;,
#           &quot;@alice @bob I&#39;ve tried to register!&quot;
#         ]
#       ]
#     ]
#   ]
# ]
</pre></div>
</div>
<p>Above query returns Bob’s favorite comments.</p>
</div>
<div class="section" id="search-comments-by-posted-time">
<h3><span class="section-number">4.10.3.10. </span>Search comments by posted time<a class="headerlink" href="#search-comments-by-posted-time" title="Permalink to this headline">¶</a></h3>
<p>In this section, we search comments by posted time.
See type of <cite>Time</cite> in <a class="reference internal" href="data.html"><span class="doc">Various data types</span></a>.</p>
<p>Let’s search comments that posted time are older than specified time.</p>
<p>Execution example:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>select Comments --filter &#39;last_modified&lt;=1268802000&#39; --output_columns posted_by.name,comment,last_modified --drilldown hash_tags,posted_by
# [
#   [
#     0,
#     1337566253.89858,
#     0.000355720520019531
#   ],
#   [
#     [
#       [
#         5
#       ],
#       [
#         [
#           &quot;posted_by.name&quot;,
#           &quot;ShortText&quot;
#         ],
#         [
#           &quot;comment&quot;,
#           &quot;ShortText&quot;
#         ],
#         [
#           &quot;last_modified&quot;,
#           &quot;Time&quot;
#         ]
#       ],
#       [
#         &quot;Alice&quot;,
#         &quot;I&#39;ve created micro-blog!&quot;,
#         1268795100.0
#       ],
#       [
#         &quot;Bob&quot;,
#         &quot;First post. test,test...&quot;,
#         1268794800.0
#       ],
#       [
#         &quot;Alice&quot;,
#         &quot;@bob Welcome!!!&quot;,
#         1268795100.0
#       ],
#       [
#         &quot;Bob&quot;,
#         &quot;@alice Thanks!&quot;,
#         1268798400.0
#       ],
#       [
#         &quot;Bob&quot;,
#         &quot;I&#39;ve just used &#39;Try-Groonga&#39; now! #groonga&quot;,
#         1268802000.0
#       ]
#     ],
#     [
#       [
#         1
#       ],
#       [
#         [
#           &quot;_key&quot;,
#           &quot;ShortText&quot;
#         ],
#         [
#           &quot;_nsubrecs&quot;,
#           &quot;Int32&quot;
#         ]
#       ],
#       [
#         &quot;groonga&quot;,
#         1
#       ]
#     ],
#     [
#       [
#         2
#       ],
#       [
#         [
#           &quot;_key&quot;,
#           &quot;ShortText&quot;
#         ],
#         [
#           &quot;_nsubrecs&quot;,
#           &quot;Int32&quot;
#         ]
#       ],
#       [
#         &quot;alice&quot;,
#         2
#       ],
#       [
#         &quot;bob&quot;,
#         3
#       ]
#     ]
#   ]
# ]
</pre></div>
</div>
<p>Above query returns 5 comments which are older than 2010/03/17 14:00:00.
It also returns result of drilldown by posted person. There are 2 comments by Alice, 3 comments by Bob.</p>
</div>
</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="#">4.10. Let’s create micro-blog</a><ul>
<li><a class="reference internal" href="#create-a-table">4.10.1. Create a table</a><ul>
<li><a class="reference internal" href="#users-table">4.10.1.1. Users table</a></li>
<li><a class="reference internal" href="#comments-table">4.10.1.2. Comments table</a></li>
<li><a class="reference internal" href="#hashtags-table">4.10.1.3. HashTags table</a></li>
<li><a class="reference internal" href="#bigram-table">4.10.1.4. Bigram table</a></li>
<li><a class="reference internal" href="#geoindex-table">4.10.1.5. GeoIndex table</a></li>
</ul>
</li>
<li><a class="reference internal" href="#loading-data">4.10.2. Loading data</a></li>
<li><a class="reference internal" href="#search">4.10.3. Search</a><ul>
<li><a class="reference internal" href="#search-users-by-keyword">4.10.3.1. Search users by keyword</a></li>
<li><a class="reference internal" href="#search-users-by-geolocation-data-geopoint">4.10.3.2. Search users by geolocation data (GeoPoint)</a></li>
<li><a class="reference internal" href="#search-users-who-follows-specific-user">4.10.3.3. Search users who follows specific user</a></li>
<li><a class="reference internal" href="#search-comments-by-using-the-value-of-geopoint-type">4.10.3.4. Search comments by using the value of GeoPoint type</a></li>
<li><a class="reference internal" href="#search-comments-by-keyword">4.10.3.5. Search comments by keyword</a></li>
<li><a class="reference internal" href="#search-comments-by-keyword-and-geolocation">4.10.3.6. Search comments by keyword and geolocation</a></li>
<li><a class="reference internal" href="#search-comments-by-hash-tags">4.10.3.7. Search comments by hash tags</a></li>
<li><a class="reference internal" href="#search-comments-by-user-id">4.10.3.8. Search comments by user id</a></li>
<li><a class="reference internal" href="#search-user-s-favorite-comments">4.10.3.9. Search user’s favorite comments</a></li>
<li><a class="reference internal" href="#search-comments-by-posted-time">4.10.3.10. Search comments by posted time</a></li>
</ul>
</li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="lexicon.html"
                        title="previous chapter"><span class="section-number">4.9. </span>Additional information about lexicon for full text search</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="query_expansion.html"
                        title="next chapter"><span class="section-number">4.11. </span>Query expansion</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="query_expansion.html" title="4.11. Query expansion"
             >next</a> |</li>
        <li class="right" >
          <a href="lexicon.html" title="4.9. Additional information about lexicon for full text search"
             >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="../tutorial.html" ><span class="section-number">4. </span>Tutorial</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href=""><span class="section-number">4.10. </span>Let’s create micro-blog</a></li> 
      </ul>
    </div>
    <div class="footer" role="contentinfo">
        &#169; Copyright 2009-2021, Brazil, Inc.
    </div>
  </body>
</html>