-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path2014-10-27.grn
210 lines (152 loc) · 7.15 KB
/
2014-10-27.grn
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
# 4.1. 基本的な操作
# 4.1.5. テーブルの作成
table_create --name Site --flags TABLE_HASH_KEY --key_type ShortText
# 4.1.7. カラムの作成
column_create --table Site --name title --flags COLUMN_SCALAR --type ShortText
# 4.1.8. データのロード
load --table Site
[
{"_key":"http://example.org/","title":"This is test record 1!"},
{"_key":"http://example.net/","title":"test record 2."},
{"_key":"http://example.com/","title":"test test record three."},
{"_key":"http://example.net/afr","title":"test record four."},
{"_key":"http://example.org/aba","title":"test test test record five."},
{"_key":"http://example.com/rab","title":"test test test test record six."},
{"_key":"http://example.net/atv","title":"test test test record seven."},
{"_key":"http://example.org/gat","title":"test test record eight."},
{"_key":"http://example.com/vdw","title":"test test record nine."}
]
# 4.1.10. 全文検索用の語彙表の作成
table_create --name Terms --flags TABLE_PAT_KEY|KEY_NORMALIZE --key_type ShortText --default_tokenizer TokenBigram
column_create --table Terms --name blog_title --flags COLUMN_INDEX|WITH_POSITION --type Site --source title
# 4.3. いろいろなデータの保存
table_create --name ToyBox --flags TABLE_HASH_KEY --key_type ShortText
# 4.3.2. 真偽値
column_create --table ToyBox --name is_animal --flags COLUMN_SCALAR --type Bool
load --table ToyBox
[
{"_key":"Monkey","is_animal":true},
{"_key":"Flower","is_animal":false}
{"_key":"Block"}
]
# 4.3.3. 数値
column_create --table ToyBox --name price --flags COLUMN_SCALAR --type Int8
column_create --table ToyBox --name weight --flags COLUMN_SCALAR --type Float
load --table ToyBox
[
{"_key":"Monkey","price":15.9},
{"_key":"Flower","price":200,"weight":0.13},
{"_key":"Block","weight":25.7}
]
# 4.3.4. 文字列
column_create --table ToyBox --name name --flags COLUMN_SCALAR --type ShortText
load --table ToyBox
[
{"_key":"Monkey","name":"Grease"},
{"_key":"Flower","name":"Rose"}
]
# 4.3.5. 日時
column_create --table ToyBox --name time --flags COLUMN_SCALAR --type Time
load --table ToyBox
[
{"_key":"Flower","time":1234567890.1234569999},
{"_key":"Block","time":-1234567890}
]
# 4.3.6. 経緯度
column_create --table ToyBox --name location --flags COLUMN_SCALAR --type WGS84GeoPoint
load --table ToyBox
[
{"_key":"Monkey","location":"128452975x503157902"},
{"_key":"Block","location":"35.6813819x139.7660839"}
]
# 4.3.7. テーブル参照
column_create --table Site --name link --flags COLUMN_SCALAR --type Site
load --table Site
[
{"_key":"http://example.org/","link":"http://example.net/"}
]
# 4.3.8. ベクターカラム
column_create --table Site --name links --flags COLUMN_VECTOR --type Site
load --table Site
[
{"_key":"http://example.org/","links":["http://example.net/","http://example.org/","http://example.com/"]}
]
# 4.4. さまざまな検索条件
# 4.4.3. 位置情報を用いた絞込・ソート
column_create --table Site --name location --flags COLUMN_SCALAR --type WGS84GeoPoint
load --table Site
[
{"_key":"http://example.org/","location":"128452975x503157902"},
{"_key":"http://example.net/","location":"128487316x502920929"}
]
# 4.5. ドリルダウン
table_create --name SiteDomain --flags TABLE_HASH_KEY --key_type ShortText
table_create --name SiteCountry --flags TABLE_HASH_KEY --key_type ShortText
column_create --table Site --name domain --flags COLUMN_SCALAR --type SiteDomain
column_create --table Site --name country --flags COLUMN_SCALAR --type SiteCountry
load --table Site
[
{"_key":"http://example.org/","domain":".org","country":"japan"},
{"_key":"http://example.net/","domain":".net","country":"brazil"},
{"_key":"http://example.com/","domain":".com","country":"japan"},
{"_key":"http://example.net/afr","domain":".net","country":"usa"},
{"_key":"http://example.org/aba","domain":".org","country":"korea"},
{"_key":"http://example.com/rab","domain":".com","country":"china"},
{"_key":"http://example.net/atv","domain":".net","country":"china"},
{"_key":"http://example.org/gat","domain":".org","country":"usa"},
{"_key":"http://example.com/vdw","domain":".com","country":"japan"}
]
# 4.6. タグ検索・参照関係の逆引き
# 4.6.1. タグ検索
table_create --name Video --flags TABLE_HASH_KEY --key_type UInt32
table_create --name Tag --flags TABLE_HASH_KEY --key_type ShortText
column_create --table Video --name title --flags COLUMN_SCALAR --type ShortText
column_create --table Video --name tags --flags COLUMN_VECTOR --type Tag
column_create --table Tag --name index_tags --flags COLUMN_INDEX --type Video --source tags
load --table Video
[
{"_key":1,"title":"Soccer 2010","tags":["Sports","Soccer"]},
{"_key":2,"title":"Zenigata Kinjirou","tags":["Variety","Money"]},
{"_key":3,"title":"groonga Demo","tags":["IT","Server","groonga"]},
{"_key":4,"title":"Moero!! Ultra Baseball","tags":["Sports","Baseball"]},
{"_key":5,"title":"Hex Gone!","tags":["Variety","Quiz"]},
{"_key":6,"title":"Pikonyan 1","tags":["Animation","Pikonyan"]},
{"_key":7,"title":"Draw 8 Month","tags":["Animation","Raccoon"]},
{"_key":8,"title":"K.O.","tags":["Animation","Music"]}
]
# 4.6.2. 参照関係の逆引き
table_create --name User --flags TABLE_HASH_KEY --key_type ShortText
column_create --table User --name username --flags COLUMN_SCALAR --type ShortText
column_create --table User --name friends --flags COLUMN_VECTOR --type User
column_create --table User --name index_friends --flags COLUMN_INDEX --type User --source friends
load --table User
[
{"_key":"ken","username":"健作","friends":["taro","jiro","tomo","moritapo"]},
{"_key":"moritapo","username":"森田","friends":["ken","tomo"]},
{"_key":"taro","username":"ぐるんが太郎","friends":["jiro","tomo"]},
{"_key":"jiro","username":"ぐるんが次郎","friends":["taro","tomo"]},
{"_key":"tomo","username":"トモちゃん","friends":["ken","hana"]},
{"_key":"hana","username":"花子","friends":["ken","taro","jiro","moritapo","tomo"]}
]
# 4.6.3. インデックス付きジオサーチ
table_create --name GeoIndex --flags TABLE_PAT_KEY --key_type WGS84GeoPoint
column_create --table GeoIndex --name index_point --type Site --flags COLUMN_INDEX --source location
load --table Site
[
{"_key":"http://example.org/","location":"128452975x503157902"},
{"_key":"http://example.net/","location":"128487316x502920929"}
]
# 4.7. match_columnsパラメータ
# 4.7.1.1. カラムごとにインデックスを付与する場合
table_create --name Blog1 --flags TABLE_HASH_KEY --key_type ShortText
column_create --table Blog1 --name title --flags COLUMN_SCALAR --type ShortText
column_create --table Blog1 --name message --flags COLUMN_SCALAR --type ShortText
table_create --name IndexBlog1 --flags TABLE_PAT_KEY|KEY_NORMALIZE --key_type ShortText --default_tokenizer TokenBigram
column_create --table IndexBlog1 --name index_title --flags COLUMN_INDEX|WITH_POSITION --type Blog1 --source title
column_create --table IndexBlog1 --name index_message --flags COLUMN_INDEX|WITH_POSITION --type Blog1 --source message
load --table Blog1
[
{"_key":"grn1","title":"groonga test","message":"groonga message"},
{"_key":"grn2","title":"baseball result","message":"rakutan eggs 4 - 4 groonga moritars"},
{"_key":"grn3","title":"groonga message","message":"none"}
]