rabbit-slide-kou-groonga-meatup-2015 2015.11.29.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.rabbit +1 -0
- data/README.rd +44 -0
- data/Rakefile +17 -0
- data/config.yaml +28 -0
- data/groonga-family-2015.rab +1698 -0
- data/images/droonga-logo.svg +73 -0
- data/images/droonga-throughput.png +0 -0
- data/images/gnavi-complete.png +0 -0
- data/images/groonga-column-store.svg +624 -0
- data/images/groonga-family-glue.svg +1252 -0
- data/images/groonga-logo.svg +118 -0
- data/images/groonga-performance-characteristic.svg +255 -0
- data/images/mroonga-logo.svg +106 -0
- data/images/pgroonga-logo.svg +84 -0
- data/images/read-while-write-gin.svg +364 -0
- data/images/read-while-write-pgroonga.svg +325 -0
- data/images/rroonga-logo.svg +117 -0
- data/pdf/groonga-meatup-2015-groonga-family-2015.pdf +0 -0
- data/theme.rb +4 -0
- metadata +92 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 706bbc41f8c48eacd6f177ef822b82bf59ba8545
|
|
4
|
+
data.tar.gz: 5f561f4ba9c994d266aee13b91e1c7872b58eed6
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 7d8db869b71aec6f4fa3d381c48b00b19adef6b11aebc1684b995f0354176280f0e7b48240344ae9c4b23c181d4c5281fa032f10740aadb0cb27884f8c94558b
|
|
7
|
+
data.tar.gz: a3ab1bb515cf6946cbc7f3ec4e2da7f8dd478d93903eb746ef0a9ee33d1654750de79b97c7fafc5451b5ca28f6a49e88bf29ce1d67d00b8a87f0828c46449a5f
|
data/.rabbit
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
groonga-family-2015.rab
|
data/README.rd
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
= Groonga族2015
|
|
2
|
+
|
|
3
|
+
Groonga、Mroonga、PGroonga、Rroonga、Droongaなど、Groonga関連プロジェクトの概要と2015年現在の最新情報を紹介します。
|
|
4
|
+
|
|
5
|
+
== ライセンス
|
|
6
|
+
|
|
7
|
+
=== スライド
|
|
8
|
+
|
|
9
|
+
CC BY-SA 4.0
|
|
10
|
+
|
|
11
|
+
原著作者名は以下の通りです。
|
|
12
|
+
|
|
13
|
+
* 須藤功平(またはKouhei Sutou)
|
|
14
|
+
|
|
15
|
+
=== 画像
|
|
16
|
+
|
|
17
|
+
==== 各種Groonga関連プロダクトのロゴ
|
|
18
|
+
|
|
19
|
+
CC BY 3.0
|
|
20
|
+
|
|
21
|
+
原著作者名は以下の通りです。
|
|
22
|
+
|
|
23
|
+
* Groongaプロジェクト
|
|
24
|
+
|
|
25
|
+
== 作者向け
|
|
26
|
+
|
|
27
|
+
=== 表示
|
|
28
|
+
|
|
29
|
+
rake
|
|
30
|
+
|
|
31
|
+
=== 公開
|
|
32
|
+
|
|
33
|
+
rake publish
|
|
34
|
+
|
|
35
|
+
== 閲覧者向け
|
|
36
|
+
|
|
37
|
+
=== インストール
|
|
38
|
+
|
|
39
|
+
gem install rabbit-slide-kou-groonga-meatup-2015
|
|
40
|
+
|
|
41
|
+
=== 表示
|
|
42
|
+
|
|
43
|
+
rabbit rabbit-slide-kou-groonga-meatup-2015.gem
|
|
44
|
+
|
data/Rakefile
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
require "rabbit/task/slide"
|
|
2
|
+
|
|
3
|
+
# Edit ./config.yaml to customize meta data
|
|
4
|
+
|
|
5
|
+
spec = nil
|
|
6
|
+
Rabbit::Task::Slide.new do |task|
|
|
7
|
+
spec = task.spec
|
|
8
|
+
# spec.files += Dir.glob("doc/**/*.*")
|
|
9
|
+
# spec.files -= Dir.glob("private/**/*.*")
|
|
10
|
+
spec.add_runtime_dependency("rabbit-theme-groonga")
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
desc "Tag #{spec.version}"
|
|
14
|
+
task :tag do
|
|
15
|
+
sh("git", "tag", "-a", spec.version.to_s, "-m", "Publish #{spec.version}")
|
|
16
|
+
sh("git", "push", "--tags")
|
|
17
|
+
end
|
data/config.yaml
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: groonga-meatup-2015
|
|
3
|
+
base_name: groonga-family-2015
|
|
4
|
+
tags:
|
|
5
|
+
- rabbit
|
|
6
|
+
- groonga
|
|
7
|
+
- mroonga
|
|
8
|
+
- pgroonga
|
|
9
|
+
- rroonga
|
|
10
|
+
- droonga
|
|
11
|
+
- full-text-search
|
|
12
|
+
presentation_date: 2015-11-29
|
|
13
|
+
version: 2015.11.29.0
|
|
14
|
+
licenses:
|
|
15
|
+
- CC BY-SA 4.0
|
|
16
|
+
- CC BY 3.0
|
|
17
|
+
slideshare_id: groonga-meatup-2015
|
|
18
|
+
speaker_deck_id:
|
|
19
|
+
ustream_id:
|
|
20
|
+
vimeo_id:
|
|
21
|
+
youtube_id:
|
|
22
|
+
author:
|
|
23
|
+
markup_language: :rd
|
|
24
|
+
name: Kouhei Sutou
|
|
25
|
+
email: kou@clear-code.com
|
|
26
|
+
rubygems_user: kou
|
|
27
|
+
slideshare_user: kou
|
|
28
|
+
speaker_deck_user: kou
|
|
@@ -0,0 +1,1698 @@
|
|
|
1
|
+
= Groonga族2015
|
|
2
|
+
|
|
3
|
+
: author
|
|
4
|
+
須藤功平
|
|
5
|
+
: institution
|
|
6
|
+
株式会社クリアコード
|
|
7
|
+
: content-source
|
|
8
|
+
Groonga Meatup 2015
|
|
9
|
+
: date
|
|
10
|
+
2015-11-29
|
|
11
|
+
: allotted-time
|
|
12
|
+
30m
|
|
13
|
+
: theme
|
|
14
|
+
.
|
|
15
|
+
|
|
16
|
+
= 内容
|
|
17
|
+
|
|
18
|
+
* Groonga族の概要
|
|
19
|
+
* Groonga族の最新情報
|
|
20
|
+
* Groonga族の今後の情報
|
|
21
|
+
|
|
22
|
+
= Groonga族
|
|
23
|
+
|
|
24
|
+
総称
|
|
25
|
+
|
|
26
|
+
= Groonga族
|
|
27
|
+
|
|
28
|
+
* ((*Groongaそのもの*))
|
|
29
|
+
* Groongaと他のプロダクトを\n
|
|
30
|
+
((*つなぐプロダクト*))
|
|
31
|
+
* ((*名前がXroonga*))
|
|
32
|
+
|
|
33
|
+
= つなぐプロダクト
|
|
34
|
+
|
|
35
|
+
# image
|
|
36
|
+
# src = images/groonga-family-glue.svg
|
|
37
|
+
# relative_width = 110
|
|
38
|
+
|
|
39
|
+
(('note:ポイント'))\n
|
|
40
|
+
(('note:Groongaはライブラリーとして他のプロダクトに埋め込める!'))
|
|
41
|
+
|
|
42
|
+
= Groonga族:Groonga
|
|
43
|
+
|
|
44
|
+
# image
|
|
45
|
+
# src = images/groonga-logo.svg
|
|
46
|
+
# relative_width = 100
|
|
47
|
+
|
|
48
|
+
(('tag:center'))
|
|
49
|
+
ぐるんが
|
|
50
|
+
|
|
51
|
+
= Groongaのよいところ1
|
|
52
|
+
|
|
53
|
+
高速な\n
|
|
54
|
+
全文検索機能\n
|
|
55
|
+
(('note:(全文検索エンジンなので当然)'))
|
|
56
|
+
|
|
57
|
+
= Groongaのよいところ2
|
|
58
|
+
|
|
59
|
+
即時更新
|
|
60
|
+
|
|
61
|
+
= 即時更新
|
|
62
|
+
|
|
63
|
+
* 更新→すぐに検索可能
|
|
64
|
+
* 思想:新鮮なデータは高価値
|
|
65
|
+
* 新しいデータはすぐに入れて!
|
|
66
|
+
* 工夫:更新中も検索性能キープ
|
|
67
|
+
* 即時データ投入を妨げる理由を減少
|
|
68
|
+
* 実装:参照ロックフリー
|
|
69
|
+
|
|
70
|
+
= 性能の傾向
|
|
71
|
+
|
|
72
|
+
# image
|
|
73
|
+
# src = images/groonga-performance-characteristic.svg
|
|
74
|
+
# relative_width = 100
|
|
75
|
+
|
|
76
|
+
= Groongaのよいところ3
|
|
77
|
+
|
|
78
|
+
高速な集計処理
|
|
79
|
+
|
|
80
|
+
= 高速な集計処理
|
|
81
|
+
|
|
82
|
+
* 集計処理
|
|
83
|
+
* 同一カラムの値を一気にアクセス
|
|
84
|
+
* 工夫:↑向けデータ構造を採用
|
|
85
|
+
* 高速な集計処理を実現
|
|
86
|
+
* 実装:カラムストア
|
|
87
|
+
|
|
88
|
+
= カラムストア
|
|
89
|
+
|
|
90
|
+
# image
|
|
91
|
+
# src = images/groonga-column-store.svg
|
|
92
|
+
# relative_width = 100
|
|
93
|
+
|
|
94
|
+
= Groongaのよいところ3
|
|
95
|
+
|
|
96
|
+
手厚い\n
|
|
97
|
+
日本語サポート
|
|
98
|
+
|
|
99
|
+
= サポート例:RKサーチ
|
|
100
|
+
|
|
101
|
+
(('tag:center'))
|
|
102
|
+
ローマ字でカナを検索\n
|
|
103
|
+
(('note:Romaji to Kana prefix search'))
|
|
104
|
+
|
|
105
|
+
* 例:「ya」→「ヤキニク」
|
|
106
|
+
* 「や」・「ヤ」→「ヤキニク」も可
|
|
107
|
+
* 用意するもの
|
|
108
|
+
* カタカナでのヨミガナだけ\n
|
|
109
|
+
(('note:(ひらがな・ローマ字はいらない)'))\n
|
|
110
|
+
(('note:(ローマ字の訓令式・ヘボン式の差はGroongaが吸収)'))
|
|
111
|
+
|
|
112
|
+
= RKサーチの利用例1
|
|
113
|
+
|
|
114
|
+
(('tag:center'))
|
|
115
|
+
(('tag:margin-bottom'))
|
|
116
|
+
入力補助
|
|
117
|
+
|
|
118
|
+
* 例:タグの入力\n
|
|
119
|
+
(('note:同じことに違うタグをつけると検索精度があがらない'))\n
|
|
120
|
+
(('note:全体で一貫性があることは重要'))\n
|
|
121
|
+
(('note:既存のタグを入力補助することで同じことに同じタグをつけやすくする'))
|
|
122
|
+
* 使い所:妥当な値の集合がある
|
|
123
|
+
* タグ入力なら既存タグ
|
|
124
|
+
|
|
125
|
+
= RKサーチの利用例2
|
|
126
|
+
|
|
127
|
+
(('tag:center'))
|
|
128
|
+
(('tag:margin-bottom'))
|
|
129
|
+
検索ボックスでの補完
|
|
130
|
+
|
|
131
|
+
* Googleもやっているやつ
|
|
132
|
+
* ぐるなびはGroongaで実現
|
|
133
|
+
|
|
134
|
+
= ぐるなびでの利用例
|
|
135
|
+
|
|
136
|
+
# image
|
|
137
|
+
# src = images/gnavi-complete.png
|
|
138
|
+
# relative_height = 70
|
|
139
|
+
|
|
140
|
+
(('tag:center'))
|
|
141
|
+
(('note:「yu」→「ユウラクチョウ」→「有楽町」'))
|
|
142
|
+
|
|
143
|
+
(('note:出典:Groongaのサジェストで四苦八苦 by Walker'))\n
|
|
144
|
+
(('note:https://speakerdeck.com/redfigure/groongafalsesaziesutodesi-ku-ba-ku'))
|
|
145
|
+
|
|
146
|
+
= 補完の使い方1
|
|
147
|
+
|
|
148
|
+
(('tag:center'))
|
|
149
|
+
スキーマ作成
|
|
150
|
+
|
|
151
|
+
% groonga-suggest-create-dataset \
|
|
152
|
+
DB_PATH stations
|
|
153
|
+
|
|
154
|
+
= 補完の使い方2
|
|
155
|
+
|
|
156
|
+
(('tag:center'))
|
|
157
|
+
データ準備
|
|
158
|
+
|
|
159
|
+
# coderay json
|
|
160
|
+
|
|
161
|
+
[
|
|
162
|
+
{
|
|
163
|
+
"_key": "有楽町",
|
|
164
|
+
"kana": ["ユウラクチョウ"],
|
|
165
|
+
"boost": 100
|
|
166
|
+
}
|
|
167
|
+
]
|
|
168
|
+
|
|
169
|
+
(('tag:center'))
|
|
170
|
+
(('note:boostを100以上にすること'))
|
|
171
|
+
|
|
172
|
+
= 補完の使い方3
|
|
173
|
+
|
|
174
|
+
(('tag:center'))
|
|
175
|
+
データロード
|
|
176
|
+
|
|
177
|
+
% curl \
|
|
178
|
+
'localhost:10041/d/load?table=item_stations' \
|
|
179
|
+
--header 'Content-Type: application/json' \
|
|
180
|
+
--data-binary @stations.json
|
|
181
|
+
|
|
182
|
+
(('note:curlを使うときは--dataではなく--data-binaryを使うこと'))\n
|
|
183
|
+
(('note:--dataは改行を削除するため'))
|
|
184
|
+
|
|
185
|
+
= 補完の使い方4
|
|
186
|
+
|
|
187
|
+
(('tag:center'))
|
|
188
|
+
補完
|
|
189
|
+
|
|
190
|
+
% curl \
|
|
191
|
+
'localhost:10041/d/suggest' \
|
|
192
|
+
--get \
|
|
193
|
+
--data-urlencode 'types=complete' \
|
|
194
|
+
--data-urlencode 'table=item_stations' \
|
|
195
|
+
--data-urlencode 'column=kana' \
|
|
196
|
+
--data-urlencode 'query=yu'
|
|
197
|
+
[
|
|
198
|
+
[...],
|
|
199
|
+
{"complete": [[1],[...],["有楽町",101]]}
|
|
200
|
+
]
|
|
201
|
+
|
|
202
|
+
= Groongaのよいところ4
|
|
203
|
+
|
|
204
|
+
組み込める
|
|
205
|
+
|
|
206
|
+
= 組み込める
|
|
207
|
+
|
|
208
|
+
* ライブラリーとして利用可能
|
|
209
|
+
* =インターフェイスを変えられる
|
|
210
|
+
* =使いやすい方法で使える
|
|
211
|
+
|
|
212
|
+
= つなぐプロダクト
|
|
213
|
+
|
|
214
|
+
# image
|
|
215
|
+
# src = images/groonga-family-glue.svg
|
|
216
|
+
# relative_width = 110
|
|
217
|
+
|
|
218
|
+
(('note:ポイント'))\n
|
|
219
|
+
(('note:Groongaはライブラリーとして他のプロダクトに埋め込める!'))
|
|
220
|
+
|
|
221
|
+
= Groonga族:Mroonga
|
|
222
|
+
|
|
223
|
+
# image
|
|
224
|
+
# src = images/mroonga-logo.svg
|
|
225
|
+
# relative_width = 100
|
|
226
|
+
|
|
227
|
+
(('tag:center'))
|
|
228
|
+
むるんが\n
|
|
229
|
+
((*M*))ySQL + G((*roonga*))
|
|
230
|
+
|
|
231
|
+
= Mroongaのよいところ1
|
|
232
|
+
|
|
233
|
+
簡単に使える
|
|
234
|
+
|
|
235
|
+
= 簡単
|
|
236
|
+
|
|
237
|
+
* SQLで使える
|
|
238
|
+
* 全文検索の知識なしで\n
|
|
239
|
+
使い始められる
|
|
240
|
+
|
|
241
|
+
= Mroongaを使う:スキーマ
|
|
242
|
+
|
|
243
|
+
# coderay sql
|
|
244
|
+
CREATE TABLE texts (
|
|
245
|
+
content TEXT,
|
|
246
|
+
FULLTEXT INDEX (content)
|
|
247
|
+
-- ↑と↓を追加
|
|
248
|
+
) ENGINE=Mroonga
|
|
249
|
+
DEFAULT CHARSET=utf8mb4;
|
|
250
|
+
|
|
251
|
+
(('tag:center'))
|
|
252
|
+
(('note:ポイント:全文検索の索引を作ると言っているだけ'))
|
|
253
|
+
|
|
254
|
+
= Mroongaを使う:検索
|
|
255
|
+
|
|
256
|
+
# coderay sql
|
|
257
|
+
SELECT * FROM texts
|
|
258
|
+
WHERE
|
|
259
|
+
MATCH(content)
|
|
260
|
+
AGAINST('*D+ キーワード1 キーワード2'
|
|
261
|
+
IN BOOLEAN MODE);
|
|
262
|
+
|
|
263
|
+
(('tag:center'))
|
|
264
|
+
(('note:ポイント:Web検索エンジンと同様にクエリーを書ける'))
|
|
265
|
+
|
|
266
|
+
= なぜ知識なしで使えるの?
|
|
267
|
+
|
|
268
|
+
適切な\n
|
|
269
|
+
デフォルト値
|
|
270
|
+
|
|
271
|
+
= デフォルト値
|
|
272
|
+
|
|
273
|
+
* トークナイザー:可変長Bigram\n
|
|
274
|
+
(('note:(トークナイザー≒検索キーワード抽出モジュール)'))
|
|
275
|
+
* 日本語+英語でもいい感じに動く
|
|
276
|
+
* ノーマライザー:MySQL互換\n
|
|
277
|
+
(('note:(ノーマライザー≒テキスト正規化モジュール)'))
|
|
278
|
+
* 一部非互換:🍣≠🍺
|
|
279
|
+
|
|
280
|
+
= Mroongaのよいところ2
|
|
281
|
+
|
|
282
|
+
MySQLの機能を\n
|
|
283
|
+
使える
|
|
284
|
+
|
|
285
|
+
= MySQLの機能
|
|
286
|
+
|
|
287
|
+
* レプリケーション
|
|
288
|
+
* ユーザー管理
|
|
289
|
+
* クライアントライブラリー
|
|
290
|
+
* ...
|
|
291
|
+
|
|
292
|
+
= Mroongaのよいところ3
|
|
293
|
+
|
|
294
|
+
速い!
|
|
295
|
+
|
|
296
|
+
= 例:MySQL 5.7と比較
|
|
297
|
+
|
|
298
|
+
(('tag:center'))
|
|
299
|
+
(('note:ポイント:MySQL 5.7のInnoDBは日本語全文検索対応!'))
|
|
300
|
+
|
|
301
|
+
# RT
|
|
302
|
+
|
|
303
|
+
クエリー, 文字数, InnoDB\nmecab, InnoDB\nbigram, Mroonga\nbigram
|
|
304
|
+
|
|
305
|
+
COUNT, 1, (('2.62s')), N/A, ((*0.74s*))
|
|
306
|
+
COUNT, 2, ((*0.07s*)), (('1.74s')), (('0.27s'))
|
|
307
|
+
ORDER BY, 1, (('2.78s')), N/A, ((*0.83s*))
|
|
308
|
+
ORDER BY, 2, ((*0.09s*)), (('2.72s')), (('0.31s'))
|
|
309
|
+
|
|
310
|
+
(('tag:center'))
|
|
311
|
+
(('note:出典:MySQLの全文検索に関するあれやこれや by yoku0825'))\n
|
|
312
|
+
(('note:http://www.slideshare.net/yoku0825/mysql-47364986'))
|
|
313
|
+
|
|
314
|
+
* InnoDB mecabは遅いことがある
|
|
315
|
+
* Mroongaは安定して速い
|
|
316
|
+
|
|
317
|
+
= MySQL 5.7で日本語全文検索
|
|
318
|
+
|
|
319
|
+
# coderay sql
|
|
320
|
+
CREATE TABLE texts (
|
|
321
|
+
content TEXT,
|
|
322
|
+
FULLTEXT INDEX (content)
|
|
323
|
+
WITH PARSER mecab -- ←がポイント
|
|
324
|
+
) ENGINE=InnoDB
|
|
325
|
+
DEFAULT CHARSET=utf8mb4;
|
|
326
|
+
|
|
327
|
+
(('tag:center'))
|
|
328
|
+
(('note:mecabの代わりにngramも指定できるが実用的ではなさそう'))\n
|
|
329
|
+
(('note:mecabを使い場合は↑の他にMeCabの設定が必要'))\n
|
|
330
|
+
(('note:https://dev.mysql.com/doc/refman/5.7/en/fulltext-search-mecab.html'))
|
|
331
|
+
|
|
332
|
+
= Mroonga vs MySQL 5.7
|
|
333
|
+
|
|
334
|
+
* Mroonga
|
|
335
|
+
* デフォルトでいい感じに動く\n
|
|
336
|
+
(('note:(選びたければ指定できる)'))
|
|
337
|
+
* 安定して速い
|
|
338
|
+
* MySQL 5.7 InnoDB
|
|
339
|
+
* パーサーを選ばないといけない\n
|
|
340
|
+
(('note:(mecab?ngram?違いは?)'))
|
|
341
|
+
* 遅いこともある
|
|
342
|
+
|
|
343
|
+
= Mroongaが速い理由:1
|
|
344
|
+
|
|
345
|
+
Groonga直結\n
|
|
346
|
+
↓\n
|
|
347
|
+
Groongaが速いと\n
|
|
348
|
+
Mroongaも速い
|
|
349
|
+
|
|
350
|
+
= Mroongaが速い理由:2
|
|
351
|
+
|
|
352
|
+
(({ORDER BY LIMIT}))を最適化
|
|
353
|
+
|
|
354
|
+
= (({ORDER BY LIMIT}))最適化
|
|
355
|
+
|
|
356
|
+
# coderay sql
|
|
357
|
+
SELECT * FROM texts
|
|
358
|
+
WHERE MATCH(content1)
|
|
359
|
+
AGAINST('...' IN BOOLEAN MODE)
|
|
360
|
+
ORDER BY priority
|
|
361
|
+
LIMIT 10;
|
|
362
|
+
|
|
363
|
+
(('tag:center'))
|
|
364
|
+
MySQLに先頭10件しか返さない\n
|
|
365
|
+
(('note:ORDER BY LIMITをMySQLが処理するより'))\n
|
|
366
|
+
(('note:Groongaが処理する方が速いので速くなる'))
|
|
367
|
+
|
|
368
|
+
= (({ORDER BY LIMIT}))最適化!
|
|
369
|
+
|
|
370
|
+
# coderay sql
|
|
371
|
+
SELECT * FROM texts
|
|
372
|
+
WHERE MATCH(content)
|
|
373
|
+
AGAINST('...' IN BOOLEAN MODE)
|
|
374
|
+
AND n_likes < 100 -- 追加
|
|
375
|
+
ORDER BY priority
|
|
376
|
+
LIMIT 10;
|
|
377
|
+
|
|
378
|
+
(('tag:center'))
|
|
379
|
+
Groonga:(({MATCH AGAINST}))以外も処理\n
|
|
380
|
+
(('note:MySQLが処理するよりGroongaが処理する方が速いので速くなる'))
|
|
381
|
+
|
|
382
|
+
= Mroongaが速い理由:3
|
|
383
|
+
|
|
384
|
+
必要なカラム\n
|
|
385
|
+
((*のみ*))\n
|
|
386
|
+
アクセス
|
|
387
|
+
|
|
388
|
+
= 必要なカラムのみアクセス
|
|
389
|
+
|
|
390
|
+
# coderay sql
|
|
391
|
+
SELECT c1, c3, c5 FROM t;
|
|
392
|
+
|
|
393
|
+
(('tag:center'))
|
|
394
|
+
(({c2})), (({c4}))にはアクセスしない\n
|
|
395
|
+
→I/Oが減って速い
|
|
396
|
+
|
|
397
|
+
= Groongaはカラムストア
|
|
398
|
+
|
|
399
|
+
(('tag:center'))
|
|
400
|
+
(('note:必要なカラムのみアクセスできる理由'))
|
|
401
|
+
|
|
402
|
+
# image
|
|
403
|
+
# src = images/groonga-column-store.svg
|
|
404
|
+
# relative_width = 100
|
|
405
|
+
|
|
406
|
+
= Groonga族:PGroonga
|
|
407
|
+
|
|
408
|
+
# image
|
|
409
|
+
# src = images/pgroonga-logo.svg
|
|
410
|
+
# relative_width = 100
|
|
411
|
+
|
|
412
|
+
(('tag:center'))
|
|
413
|
+
ぴーじーるんが\n
|
|
414
|
+
((*P*))ost((*g*))reSQL + ((*Groonga*))
|
|
415
|
+
|
|
416
|
+
= PGroongaのよいところ1
|
|
417
|
+
|
|
418
|
+
簡単に使える
|
|
419
|
+
|
|
420
|
+
= 簡単
|
|
421
|
+
|
|
422
|
+
* SQLで使える
|
|
423
|
+
* 全文検索の知識なしで\n
|
|
424
|
+
使い始められる
|
|
425
|
+
|
|
426
|
+
= PGroongaを使う:索引
|
|
427
|
+
|
|
428
|
+
# coderay sql
|
|
429
|
+
CREATE INDEX name ON texts
|
|
430
|
+
USING pgroonga (content);
|
|
431
|
+
|
|
432
|
+
(('tag:center'))
|
|
433
|
+
(('note:ポイント:全文検索の索引を作ると言っているだけ'))
|
|
434
|
+
|
|
435
|
+
= PGroongaを使う:検索
|
|
436
|
+
|
|
437
|
+
# coderay sql
|
|
438
|
+
SELECT * FROM texts
|
|
439
|
+
WHERE
|
|
440
|
+
content @@ 'キーワード1 キーワード2';
|
|
441
|
+
|
|
442
|
+
(('tag:center'))
|
|
443
|
+
(('note:ポイント:Web検索エンジンと同様にクエリーを書ける'))
|
|
444
|
+
|
|
445
|
+
= なぜ知識なしで使えるの?
|
|
446
|
+
|
|
447
|
+
適切な\n
|
|
448
|
+
デフォルト値
|
|
449
|
+
|
|
450
|
+
= デフォルト値
|
|
451
|
+
|
|
452
|
+
* トークナイザー:可変長Bigram\n
|
|
453
|
+
(('note:(トークナイザー≒検索キーワード抽出モジュール)'))
|
|
454
|
+
* 日本語+英語でもいい感じに動く
|
|
455
|
+
* ノーマライザー:NFKC\n
|
|
456
|
+
(('note:(ノーマライザー≒テキスト正規化モジュール)'))
|
|
457
|
+
* Unicode正規化形式の1つ
|
|
458
|
+
|
|
459
|
+
= PGroongaのよいところ2
|
|
460
|
+
|
|
461
|
+
PostgreSQLの\n
|
|
462
|
+
機能を使える
|
|
463
|
+
|
|
464
|
+
= PostgreSQLの機能
|
|
465
|
+
|
|
466
|
+
* トランザクション
|
|
467
|
+
* ユーザー管理
|
|
468
|
+
* クライアントライブラリー
|
|
469
|
+
* ...
|
|
470
|
+
|
|
471
|
+
= PGroongaのよいところ3
|
|
472
|
+
|
|
473
|
+
速い!
|
|
474
|
+
|
|
475
|
+
= 例:pg_bigmと比較
|
|
476
|
+
|
|
477
|
+
(('tag:center'))
|
|
478
|
+
(('note:ポイント:PostgreSQL標準では日本語全文検索非対応'))
|
|
479
|
+
|
|
480
|
+
# RT
|
|
481
|
+
delimiter = [|]
|
|
482
|
+
|
|
483
|
+
ヒット数 | PGroonga | pg_bigm
|
|
484
|
+
|
|
485
|
+
368 | ((*0.030s*)) | (('0.107s'))
|
|
486
|
+
17,172 | ((*0.121s*)) | (('1.224s'))
|
|
487
|
+
22,885 | ((*0.179s*)) | (('2.472s'))
|
|
488
|
+
625,792(*) | (('0.646s')) | ((*0.556s*))
|
|
489
|
+
|
|
490
|
+
(('note:データ:Wikipedia日本語版'))\n
|
|
491
|
+
(('note:約184万レコード・平均サイズ約3.8KB'))\n
|
|
492
|
+
(('note:詳細:http://www.clear-code.com/blog/2015/5/25.html'))
|
|
493
|
+
|
|
494
|
+
(('note:(*) 他は検索語が3文字以上でこれだけ2文字'))
|
|
495
|
+
|
|
496
|
+
(('tag:center'))
|
|
497
|
+
PGroongaは安定して速い!
|
|
498
|
+
|
|
499
|
+
= 更新中も性能維持
|
|
500
|
+
|
|
501
|
+
# image
|
|
502
|
+
# src = images/groonga-performance-characteristic.svg
|
|
503
|
+
# relative_width = 100
|
|
504
|
+
|
|
505
|
+
= GINと更新と参照
|
|
506
|
+
|
|
507
|
+
# image
|
|
508
|
+
# src = images/read-while-write-gin.svg
|
|
509
|
+
# relative_height = 95
|
|
510
|
+
|
|
511
|
+
(('tag:center'))
|
|
512
|
+
(('note:GINはpg_bigmが使っているPostgreSQL標準の転置索引実装'))
|
|
513
|
+
|
|
514
|
+
= PGroongaと更新と参照
|
|
515
|
+
|
|
516
|
+
# image
|
|
517
|
+
# src = images/read-while-write-pgroonga.svg
|
|
518
|
+
# relative_height = 95
|
|
519
|
+
|
|
520
|
+
(('tag:center'))
|
|
521
|
+
(('note:PGroongaはGroongaを使っているので参照ロックフリー'))
|
|
522
|
+
|
|
523
|
+
= ロード時間も速い
|
|
524
|
+
|
|
525
|
+
# RT
|
|
526
|
+
delimiter = [|]
|
|
527
|
+
|
|
528
|
+
元データの\nロード時間 | 索引\n作成時間\nPGroonga | 索引\n作成時間\npg_bigm
|
|
529
|
+
|
|
530
|
+
16分31秒 | 25分37秒 | 5時間56分15秒
|
|
531
|
+
|
|
532
|
+
(('note:データ:Wikipedia日本語版'))\n
|
|
533
|
+
(('note:約184万レコード・平均サイズ約3.8KB'))\n
|
|
534
|
+
(('note:詳細:http://www.clear-code.com/blog/2015/5/25.html'))
|
|
535
|
+
|
|
536
|
+
(('tag:center'))
|
|
537
|
+
pg_bigmより約14倍速い!
|
|
538
|
+
|
|
539
|
+
= Groonga族:Rroonga
|
|
540
|
+
|
|
541
|
+
# image
|
|
542
|
+
# src = images/rroonga-logo.svg
|
|
543
|
+
# relative_width = 100
|
|
544
|
+
|
|
545
|
+
(('tag:center'))
|
|
546
|
+
るるんが\n
|
|
547
|
+
((*R*))uby + ((*Groonga*))
|
|
548
|
+
|
|
549
|
+
= Rroongaのよいところ1
|
|
550
|
+
|
|
551
|
+
Rubyで書ける
|
|
552
|
+
|
|
553
|
+
= RubyでDB作成
|
|
554
|
+
|
|
555
|
+
# coderay ruby
|
|
556
|
+
|
|
557
|
+
Groonga::Database.create(:path => "/tmp/db")
|
|
558
|
+
|
|
559
|
+
= Rubyでテーブル定義
|
|
560
|
+
|
|
561
|
+
# coderay ruby
|
|
562
|
+
|
|
563
|
+
Groonga::Schema.define do |schema|
|
|
564
|
+
schema.create_table("Users",
|
|
565
|
+
:type => :hash) do |table|
|
|
566
|
+
table.short_text("name")
|
|
567
|
+
table.int8("age")
|
|
568
|
+
end
|
|
569
|
+
end
|
|
570
|
+
|
|
571
|
+
= Rubyでデータロード
|
|
572
|
+
|
|
573
|
+
# coderay ruby
|
|
574
|
+
|
|
575
|
+
users = Groonga["Users"]
|
|
576
|
+
users.add("alice",
|
|
577
|
+
:name => "Alice",
|
|
578
|
+
:age => 29)
|
|
579
|
+
|
|
580
|
+
= Rubyでデータロード
|
|
581
|
+
|
|
582
|
+
# coderay ruby
|
|
583
|
+
|
|
584
|
+
users = Groonga["Users"]
|
|
585
|
+
users.add("alice",
|
|
586
|
+
:name => "Alice",
|
|
587
|
+
:age => 29)
|
|
588
|
+
|
|
589
|
+
= Rubyで検索
|
|
590
|
+
|
|
591
|
+
# coderay ruby
|
|
592
|
+
|
|
593
|
+
twentys = users.select do |record|
|
|
594
|
+
(record.age >= 20) & (record.age < 30)
|
|
595
|
+
end
|
|
596
|
+
twentys.each do |twenty|
|
|
597
|
+
p twenty.name # => "Alice"
|
|
598
|
+
end
|
|
599
|
+
|
|
600
|
+
= Rroongaのよいところ2
|
|
601
|
+
|
|
602
|
+
サーバーいらず
|
|
603
|
+
|
|
604
|
+
= サーバーいらず
|
|
605
|
+
|
|
606
|
+
* ローカルのDBを操作
|
|
607
|
+
* SQLiteと同じ
|
|
608
|
+
* 向き不向き
|
|
609
|
+
* 向き:1台で扱えるデータ量
|
|
610
|
+
* 不向き:1台で扱えないデータ量
|
|
611
|
+
|
|
612
|
+
= Rroongaの利用事例1
|
|
613
|
+
|
|
614
|
+
Milkode\n
|
|
615
|
+
ソースコード\n
|
|
616
|
+
検索\n
|
|
617
|
+
(('note:http://milkode.ongaeshi.me/'))
|
|
618
|
+
|
|
619
|
+
= Mlikode
|
|
620
|
+
|
|
621
|
+
* 行指向のソースコード検索\n
|
|
622
|
+
(('note:grepの親戚'))
|
|
623
|
+
* 数万ファイルも余裕
|
|
624
|
+
* grepだと遅いけど1台で扱える量
|
|
625
|
+
* 検索方法
|
|
626
|
+
* Rroongaでファイル検索
|
|
627
|
+
* →絞り込んだファイルをgrep\n
|
|
628
|
+
(('note:ポイント:絞り込んだ後ならgrepでも速い!'))
|
|
629
|
+
|
|
630
|
+
= Rroongaの利用事例2
|
|
631
|
+
|
|
632
|
+
ROMA\n
|
|
633
|
+
分散KVS\n
|
|
634
|
+
(('note:http://roma-kvs.org/'))
|
|
635
|
+
|
|
636
|
+
= ROMA
|
|
637
|
+
|
|
638
|
+
* Rakuten/Ruby\n
|
|
639
|
+
On-Memory\n
|
|
640
|
+
Architecture
|
|
641
|
+
* Rubyで実装された分散KVS
|
|
642
|
+
* ストレージにGroongaを利用\n
|
|
643
|
+
(('note:Tokyo Cabinetも使える'))
|
|
644
|
+
|
|
645
|
+
= Rroongaの利用事例3
|
|
646
|
+
|
|
647
|
+
Droonga
|
|
648
|
+
|
|
649
|
+
= Groonga族:Droonga
|
|
650
|
+
|
|
651
|
+
# image
|
|
652
|
+
# src = images/droonga-logo.svg
|
|
653
|
+
# relative_width = 100
|
|
654
|
+
|
|
655
|
+
(('tag:center'))
|
|
656
|
+
どゅるんが\n
|
|
657
|
+
((*D*))istributed ((*Groonga*))\n
|
|
658
|
+
(('note:分散対応Groonga'))
|
|
659
|
+
|
|
660
|
+
= Droongaのよいところ1
|
|
661
|
+
|
|
662
|
+
分散機能
|
|
663
|
+
|
|
664
|
+
= 分散機能
|
|
665
|
+
|
|
666
|
+
* レプリケーション:実装済み\n
|
|
667
|
+
(('note:ダウンタイムなしでノード追加可能'))
|
|
668
|
+
* データ複製
|
|
669
|
+
* 参照性能・可用性向上
|
|
670
|
+
* シャーディング:実装予定
|
|
671
|
+
* データ分割
|
|
672
|
+
* 更新性能・最大データ量向上
|
|
673
|
+
|
|
674
|
+
= レプリケーション時の性能
|
|
675
|
+
|
|
676
|
+
# image
|
|
677
|
+
# src = images/droonga-throughput.png
|
|
678
|
+
# relative_width = 100
|
|
679
|
+
|
|
680
|
+
= Droongaのよいところ2
|
|
681
|
+
|
|
682
|
+
Groonga互換API
|
|
683
|
+
|
|
684
|
+
= Groonga互換API
|
|
685
|
+
|
|
686
|
+
* Groongaと同じように使える
|
|
687
|
+
* Groongaからの移行手順あり\n
|
|
688
|
+
(('note:http://droonga.org/ja/tutorial/groonga/'))
|
|
689
|
+
* DroongaからGroongaも可
|
|
690
|
+
* クライアント無変更で動く
|
|
691
|
+
|
|
692
|
+
= 概要のまとめ
|
|
693
|
+
|
|
694
|
+
* Groonga:高速・日本語得意
|
|
695
|
+
* Mroonga:高速・簡単
|
|
696
|
+
* PGroonga:高速・簡単
|
|
697
|
+
* Rroonga:高速・手軽
|
|
698
|
+
* Droonga:高速・スケーラブル
|
|
699
|
+
|
|
700
|
+
= 最新情報
|
|
701
|
+
|
|
702
|
+
= 最新情報:Groonga
|
|
703
|
+
|
|
704
|
+
# image
|
|
705
|
+
# src = images/groonga-logo.svg
|
|
706
|
+
# relative_width = 100
|
|
707
|
+
|
|
708
|
+
(('tag:center'))
|
|
709
|
+
ぐるんが
|
|
710
|
+
|
|
711
|
+
= Groonga: 1
|
|
712
|
+
|
|
713
|
+
groonga-httpdを\n
|
|
714
|
+
正式機能に
|
|
715
|
+
|
|
716
|
+
= groonga-httpd
|
|
717
|
+
|
|
718
|
+
* nginxにGroongaを組み込み
|
|
719
|
+
* Groonga族
|
|
720
|
+
* nginxのモジュールとして実装
|
|
721
|
+
* Groonga HTTPサーバー互換
|
|
722
|
+
* ↑より高機能(('note:(HTTPサーバーとして)'))
|
|
723
|
+
* 認証・TLS・HTTP/2
|
|
724
|
+
|
|
725
|
+
= Groonga: 2
|
|
726
|
+
|
|
727
|
+
Windowsでの\n
|
|
728
|
+
DBサイズ減少\n
|
|
729
|
+
(('note:(1/3以下になるケースもあり)'))
|
|
730
|
+
|
|
731
|
+
= Groonga: 3
|
|
732
|
+
|
|
733
|
+
ドリルダウンの\n
|
|
734
|
+
高機能化
|
|
735
|
+
|
|
736
|
+
= ドリルダウンの高機能化1
|
|
737
|
+
|
|
738
|
+
(('tag:center'))
|
|
739
|
+
(('tag:margin-bottom'))
|
|
740
|
+
集計処理を追加
|
|
741
|
+
|
|
742
|
+
* 既存:
|
|
743
|
+
* カウントのみ
|
|
744
|
+
* 追加:
|
|
745
|
+
* 合計・最小値・最大値・平均
|
|
746
|
+
|
|
747
|
+
= ドリルダウン+平均
|
|
748
|
+
|
|
749
|
+
(('tag:center'))\n
|
|
750
|
+
グループでドリルダウンして\n
|
|
751
|
+
グループ毎の平均年齢も計算
|
|
752
|
+
|
|
753
|
+
% curl \
|
|
754
|
+
'localhost:10041/d/select' \
|
|
755
|
+
--get \
|
|
756
|
+
--data-urlencode 'table=users' \
|
|
757
|
+
--data-urlencode 'drilldown=group' \
|
|
758
|
+
--data-urlencode 'drilldown_calc_types=AVG' \
|
|
759
|
+
--data-urlencode 'drilldown_calc_target=age' \
|
|
760
|
+
--data-urlencode 'drilldown_output_columns=_key,_avg'
|
|
761
|
+
|
|
762
|
+
= 平均の出力例
|
|
763
|
+
|
|
764
|
+
# coderay json
|
|
765
|
+
[... [
|
|
766
|
+
[100], # 100グループ
|
|
767
|
+
[
|
|
768
|
+
["_key", "ShortText"],
|
|
769
|
+
["_avg", "Float"]
|
|
770
|
+
],
|
|
771
|
+
[
|
|
772
|
+
["グループ1", 29.0], # 平均29.0歳
|
|
773
|
+
["グループ2", 22.9], # 平均22.9歳
|
|
774
|
+
...
|
|
775
|
+
]]]
|
|
776
|
+
|
|
777
|
+
= ドリルダウンの高機能化2
|
|
778
|
+
|
|
779
|
+
(('tag:center'))
|
|
780
|
+
(('tag:margin-bottom'))
|
|
781
|
+
複数キーでのドリルダウン\n
|
|
782
|
+
↓\n
|
|
783
|
+
クロス集計
|
|
784
|
+
|
|
785
|
+
(('tag:center'))
|
|
786
|
+
例:市と年齢でのクロス集計
|
|
787
|
+
|
|
788
|
+
# RT
|
|
789
|
+
|
|
790
|
+
市\年齢, 20歳, 21歳
|
|
791
|
+
|
|
792
|
+
札幌市, 999人, 100人
|
|
793
|
+
仙台市, 500人, 200人
|
|
794
|
+
|
|
795
|
+
= 複数キードリルダウン例
|
|
796
|
+
|
|
797
|
+
(('tag:center'))
|
|
798
|
+
市と年齢でドリルダウン
|
|
799
|
+
|
|
800
|
+
% curl \
|
|
801
|
+
'localhost:10041/d/select' \
|
|
802
|
+
--get \
|
|
803
|
+
--data-urlencode 'table=users' \
|
|
804
|
+
--data-urlencode \
|
|
805
|
+
'drilldown[city_age].keys=city,age' \
|
|
806
|
+
--data-urlencode \
|
|
807
|
+
'drilldown[city_age].output_columns=
|
|
808
|
+
_value.city,_value.age,_nsubrecs'
|
|
809
|
+
|
|
810
|
+
= 出力例
|
|
811
|
+
|
|
812
|
+
# coderay json
|
|
813
|
+
[... [
|
|
814
|
+
[100], # 100パターン
|
|
815
|
+
[
|
|
816
|
+
["city", "ShortText"],
|
|
817
|
+
["age", "Int8"]
|
|
818
|
+
["_nsubrecs", "Int32"]
|
|
819
|
+
],
|
|
820
|
+
[
|
|
821
|
+
["札幌市", 20, 999], # 札幌市の20歳は999人
|
|
822
|
+
["札幌市", 21, 100], # 札幌市の21歳は100人
|
|
823
|
+
["仙台市", 20, 500], # 仙台市の20歳は500人
|
|
824
|
+
...
|
|
825
|
+
]]]
|
|
826
|
+
|
|
827
|
+
= Groonga: 4
|
|
828
|
+
|
|
829
|
+
リクエスト\n
|
|
830
|
+
キャンセル\n
|
|
831
|
+
対応
|
|
832
|
+
|
|
833
|
+
= リクエストキャンセル
|
|
834
|
+
|
|
835
|
+
% curl \
|
|
836
|
+
'localhost:10041/d/select' \
|
|
837
|
+
--get \
|
|
838
|
+
--data-urlencode 'table=users' \
|
|
839
|
+
--data-urlencode 'request_id=XXX' &
|
|
840
|
+
% curl \
|
|
841
|
+
'localhost:10041/d/request_cancel' \
|
|
842
|
+
--get \
|
|
843
|
+
--data-urlencode 'id=XXX'
|
|
844
|
+
|
|
845
|
+
(('note:注:リクエストIDを重複無く付けることはクライアントの責任'))
|
|
846
|
+
|
|
847
|
+
= Groonga: 5
|
|
848
|
+
|
|
849
|
+
(({dump}))の\n
|
|
850
|
+
ストリーム対応
|
|
851
|
+
|
|
852
|
+
= (({dump}))のストリーム対応
|
|
853
|
+
|
|
854
|
+
* Before
|
|
855
|
+
* メモリー上で全部作ってから出力
|
|
856
|
+
* 大きなDBではメモリー使用量が多い
|
|
857
|
+
* After
|
|
858
|
+
* ダンプ内容を順次出力
|
|
859
|
+
* 大きなDBでもメモリー消費が少ない
|
|
860
|
+
|
|
861
|
+
= Groonga: 6
|
|
862
|
+
|
|
863
|
+
シャーディング\n
|
|
864
|
+
対応
|
|
865
|
+
|
|
866
|
+
= シャーディング対応
|
|
867
|
+
|
|
868
|
+
* 同一DB内
|
|
869
|
+
* 複数のホストにデータ分散ではない
|
|
870
|
+
* 目的
|
|
871
|
+
* テーブルの最大レコード数制限突破\n
|
|
872
|
+
(('note:1テーブルあたり最大約2億レコード'))
|
|
873
|
+
* サポート
|
|
874
|
+
* 月・日でのシャーディング
|
|
875
|
+
|
|
876
|
+
= シャーディング:定義
|
|
877
|
+
|
|
878
|
+
% curl 'localhost:10041/d/table_create' \
|
|
879
|
+
--get \
|
|
880
|
+
--data-urlencode 'name=Logs_20151129' \
|
|
881
|
+
--data-urlencode 'flags=TABLE_NO_KEY'
|
|
882
|
+
% curl 'localhost:10041/d/column_create' \
|
|
883
|
+
--get \
|
|
884
|
+
--data-urlencode 'table=Logs_20151129' \
|
|
885
|
+
--data-urlencode 'name=timestamp' \
|
|
886
|
+
--data-urlencode 'flags=COLUMN_SCALAR' \
|
|
887
|
+
--data-urlencode 'type=Time'
|
|
888
|
+
|
|
889
|
+
= シャーディング:ロード
|
|
890
|
+
|
|
891
|
+
# coderay json
|
|
892
|
+
[
|
|
893
|
+
{"timestamp": "2015-11-29 00:00:29"},
|
|
894
|
+
{"timestamp": "2015-11-29 00:00:30"},
|
|
895
|
+
{"timestamp": "2015-11-29 00:00:31"}
|
|
896
|
+
]
|
|
897
|
+
|
|
898
|
+
= シャーディング:準備
|
|
899
|
+
|
|
900
|
+
% curl 'localhost:10041/d/plugin_register' \
|
|
901
|
+
--gets \
|
|
902
|
+
--data-urlencode 'name=sharding'
|
|
903
|
+
|
|
904
|
+
= シャーディング:検索
|
|
905
|
+
|
|
906
|
+
logical_select \
|
|
907
|
+
--logical_table Logs \
|
|
908
|
+
--shard_key timestamp \
|
|
909
|
+
--min "2015-11-29 00:00:00" \
|
|
910
|
+
--min_border "include" \
|
|
911
|
+
--max "2015-11-30 00:00:00" \
|
|
912
|
+
--max_border "exclude" \
|
|
913
|
+
--filter "..."
|
|
914
|
+
|
|
915
|
+
= Groonga: 7
|
|
916
|
+
|
|
917
|
+
正規表現対応
|
|
918
|
+
|
|
919
|
+
= 正規表現
|
|
920
|
+
|
|
921
|
+
* 構文はRubyと同じ
|
|
922
|
+
* エンジンがRubyと同じだから
|
|
923
|
+
* 一部のパターンは索引を使える
|
|
924
|
+
* 前方一致:(({\A#{リテラル}}))
|
|
925
|
+
* 中間一致:(({#{リテラル}}))
|
|
926
|
+
* 後方一致:(({#{リテラル}\z}))
|
|
927
|
+
|
|
928
|
+
= 正規表現:使い方
|
|
929
|
+
|
|
930
|
+
select \
|
|
931
|
+
--filter 'content @~ "\\AHello"'
|
|
932
|
+
|
|
933
|
+
* 演算子は(({@~}))
|
|
934
|
+
* エスケープが煩雑なので注意
|
|
935
|
+
|
|
936
|
+
= Groonga: 8
|
|
937
|
+
|
|
938
|
+
カスタム\n
|
|
939
|
+
スコア関数対応
|
|
940
|
+
|
|
941
|
+
= スコア関数
|
|
942
|
+
|
|
943
|
+
* 文書がどのくらいクエリーに\n
|
|
944
|
+
適合しているかの度合いを返す\n
|
|
945
|
+
関数
|
|
946
|
+
* これまではTFのみ
|
|
947
|
+
* TF=単語の出現数
|
|
948
|
+
* =単語の出現数がスコア
|
|
949
|
+
|
|
950
|
+
= 新スコア関数
|
|
951
|
+
|
|
952
|
+
* (({score_tf_idf}))
|
|
953
|
+
* TF-IDFベースのスコア関数
|
|
954
|
+
* 単語の出現数を単語の重要度で補正
|
|
955
|
+
* (({score_tf_at_most}))
|
|
956
|
+
* 上限値付きTFベースのスコア関数
|
|
957
|
+
* スパマー対策ならこれで十分
|
|
958
|
+
|
|
959
|
+
= スコア関数:使い方
|
|
960
|
+
|
|
961
|
+
select Logs \
|
|
962
|
+
--match_columns \
|
|
963
|
+
"scorer_tf_at_most(body, 3.0)" \
|
|
964
|
+
--query "keyword1 keyword2"
|
|
965
|
+
|
|
966
|
+
(('tag:center'))
|
|
967
|
+
(({match_columns}))で指定
|
|
968
|
+
|
|
969
|
+
= Groonga: 9
|
|
970
|
+
|
|
971
|
+
ログ\n
|
|
972
|
+
ローテーション\n
|
|
973
|
+
対応
|
|
974
|
+
|
|
975
|
+
= ログローテーション
|
|
976
|
+
|
|
977
|
+
* 使い方
|
|
978
|
+
* groongaコマンドの起動オプション
|
|
979
|
+
* オプション
|
|
980
|
+
* (({--log-rotate-threshold-size}))
|
|
981
|
+
* (({--query-log-rotate-threshold-size}))
|
|
982
|
+
|
|
983
|
+
= Groonga: 10
|
|
984
|
+
|
|
985
|
+
キャッシュの\n
|
|
986
|
+
最大キーサイズ\n
|
|
987
|
+
増加
|
|
988
|
+
|
|
989
|
+
= キャッシュのキーサイズ
|
|
990
|
+
|
|
991
|
+
* Before
|
|
992
|
+
* 4KiB
|
|
993
|
+
* After
|
|
994
|
+
* 64KiB - 1
|
|
995
|
+
|
|
996
|
+
= Groonga: 11
|
|
997
|
+
|
|
998
|
+
(({io_flush}))追加
|
|
999
|
+
|
|
1000
|
+
= (({io_flush}))
|
|
1001
|
+
|
|
1002
|
+
* メモリー上のデータを\n
|
|
1003
|
+
ディスクに書き込むコマンド
|
|
1004
|
+
* 通常はOSに任せている
|
|
1005
|
+
* 目的:クラッシュ対策
|
|
1006
|
+
* UNIX: プロセスが死んでもカーネルが生きていればいずれ書き込まれる
|
|
1007
|
+
* Windows: プロセスが死ぬと書き込まれない
|
|
1008
|
+
|
|
1009
|
+
= Groonga: 12
|
|
1010
|
+
|
|
1011
|
+
使った索引を\n
|
|
1012
|
+
ログ出力
|
|
1013
|
+
|
|
1014
|
+
= 使った索引をログ出力
|
|
1015
|
+
|
|
1016
|
+
* チューニングに便利
|
|
1017
|
+
* SQLの(({EXPLAIN}))の不便バージョン\n
|
|
1018
|
+
(('note:サーバーのログを確認しないといけないから'))
|
|
1019
|
+
* ログレベルに注意
|
|
1020
|
+
* デフォルトでは出力されない
|
|
1021
|
+
* (({debug}))にすること
|
|
1022
|
+
|
|
1023
|
+
= Groonga: 13
|
|
1024
|
+
|
|
1025
|
+
Windows\n
|
|
1026
|
+
イベントログ\n
|
|
1027
|
+
対応
|
|
1028
|
+
|
|
1029
|
+
= Windowsイベントログ
|
|
1030
|
+
|
|
1031
|
+
(('tag:center'))
|
|
1032
|
+
使い方
|
|
1033
|
+
|
|
1034
|
+
% groonga --use-windows-event-log
|
|
1035
|
+
|
|
1036
|
+
= Groonga: 14
|
|
1037
|
+
|
|
1038
|
+
スレッド数の\n
|
|
1039
|
+
動的変更対応
|
|
1040
|
+
|
|
1041
|
+
= スレッド数変更
|
|
1042
|
+
|
|
1043
|
+
(('tag:center'))
|
|
1044
|
+
最大8スレッドに変更する例
|
|
1045
|
+
|
|
1046
|
+
% curl \
|
|
1047
|
+
'localhost:10041/d/thread_limit' \
|
|
1048
|
+
--get \
|
|
1049
|
+
--data-urlencode 'max=8'
|
|
1050
|
+
|
|
1051
|
+
= Groonga: 15
|
|
1052
|
+
|
|
1053
|
+
(({column_copy}))追加
|
|
1054
|
+
|
|
1055
|
+
= (({column_copy}))
|
|
1056
|
+
|
|
1057
|
+
* カラムの値をコピー
|
|
1058
|
+
* サーバーサイドで実行
|
|
1059
|
+
* 利用例
|
|
1060
|
+
* テーブル・カラム定義変更
|
|
1061
|
+
* 新カラム作成→コピー→
|
|
1062
|
+
* 旧カラム削除→リネーム
|
|
1063
|
+
|
|
1064
|
+
= Groonga: 16
|
|
1065
|
+
|
|
1066
|
+
Pretty print\n
|
|
1067
|
+
対応
|
|
1068
|
+
|
|
1069
|
+
= 従来
|
|
1070
|
+
|
|
1071
|
+
% curl 'localhost:10041/d/status'
|
|
1072
|
+
[[0,...],{"alloc_count":248,...}]
|
|
1073
|
+
|
|
1074
|
+
= Pretty print
|
|
1075
|
+
|
|
1076
|
+
% curl \
|
|
1077
|
+
'localhost:10041/d/status' \
|
|
1078
|
+
--get \
|
|
1079
|
+
--data-urlencode 'output_pretty=yes'
|
|
1080
|
+
[
|
|
1081
|
+
[
|
|
1082
|
+
0,
|
|
1083
|
+
...
|
|
1084
|
+
],
|
|
1085
|
+
{
|
|
1086
|
+
"alloc_count": 248,
|
|
1087
|
+
...
|
|
1088
|
+
}
|
|
1089
|
+
]
|
|
1090
|
+
|
|
1091
|
+
= Groonga: 17
|
|
1092
|
+
|
|
1093
|
+
新コマンド
|
|
1094
|
+
|
|
1095
|
+
= 新コマンド
|
|
1096
|
+
|
|
1097
|
+
* (({reindex}))
|
|
1098
|
+
* 既存インデックスを再作成
|
|
1099
|
+
* (({schema}))
|
|
1100
|
+
* スキーマを返す
|
|
1101
|
+
* (({thread_limit}))
|
|
1102
|
+
* 最大スレッド数を動的に変更
|
|
1103
|
+
|
|
1104
|
+
= Groonga: 18
|
|
1105
|
+
|
|
1106
|
+
新関数
|
|
1107
|
+
|
|
1108
|
+
= 新関数
|
|
1109
|
+
|
|
1110
|
+
* (({prefix_rk_search()}))
|
|
1111
|
+
* ローマ字で検索
|
|
1112
|
+
* (({select}))で補完できる
|
|
1113
|
+
|
|
1114
|
+
= Groonga: 19
|
|
1115
|
+
|
|
1116
|
+
Groonga Admin\n
|
|
1117
|
+
進化
|
|
1118
|
+
|
|
1119
|
+
= Groonga Admin
|
|
1120
|
+
|
|
1121
|
+
* Groongaの新しい管理画面
|
|
1122
|
+
* 旧:Webからコマンドを実行できる
|
|
1123
|
+
* 新:詳細を知らずに使える
|
|
1124
|
+
* 試せる
|
|
1125
|
+
* (('note:http://packages.groonga.org:10041/'))
|
|
1126
|
+
|
|
1127
|
+
= 最新情報:Mroonga
|
|
1128
|
+
|
|
1129
|
+
# image
|
|
1130
|
+
# src = images/mroonga-logo.svg
|
|
1131
|
+
# relative_width = 100
|
|
1132
|
+
|
|
1133
|
+
(('tag:center'))
|
|
1134
|
+
むるんが\n
|
|
1135
|
+
((*M*))ySQL + G((*roonga*))
|
|
1136
|
+
|
|
1137
|
+
= Mroonga: 1
|
|
1138
|
+
|
|
1139
|
+
mroonga_boolean_mode_syntax_flags
|
|
1140
|
+
|
|
1141
|
+
* (({IN BOOLEAN MODE}))での構文を変更
|
|
1142
|
+
* スクリプト構文→使える演算子が増加
|
|
1143
|
+
|
|
1144
|
+
= スクリプト構文
|
|
1145
|
+
|
|
1146
|
+
# coderay sql
|
|
1147
|
+
SET mroonga_boolean_mode_syntax_flags =
|
|
1148
|
+
"SYNTAX_SCRIPT";
|
|
1149
|
+
|
|
1150
|
+
SELECT * FROM memos
|
|
1151
|
+
WHERE MATCH(title)
|
|
1152
|
+
AGAINST('title @~ ".+roonga"'
|
|
1153
|
+
IN BOOLEAN MODE);
|
|
1154
|
+
|
|
1155
|
+
(('note:正規表現を使う例'))\n
|
|
1156
|
+
(('note:他にも関数を使えたり比較演算子を使えたりする'))\n
|
|
1157
|
+
(('note:MATCHに指定していないカラムでも検索できる'))
|
|
1158
|
+
|
|
1159
|
+
= Mroonga: 2
|
|
1160
|
+
|
|
1161
|
+
MariaDB\n
|
|
1162
|
+
カスタム\n
|
|
1163
|
+
パラメーター\n
|
|
1164
|
+
対応
|
|
1165
|
+
|
|
1166
|
+
= インデックスパラメーター
|
|
1167
|
+
|
|
1168
|
+
# coderay sql
|
|
1169
|
+
|
|
1170
|
+
CREATE TABLE memos (
|
|
1171
|
+
body text,
|
|
1172
|
+
FULLTEXT INDEX body_index (body)
|
|
1173
|
+
TOKENIZER='TokenMecab'
|
|
1174
|
+
NORMALIZER='NormalizerAuto'
|
|
1175
|
+
TOKEN_FILTERS='TokenFilterStopWord'
|
|
1176
|
+
-- ↑COMMENTに書かなくてよい!
|
|
1177
|
+
) ENGINE=Mroonga DEFAULT CHARSET=utf8mb4;
|
|
1178
|
+
|
|
1179
|
+
= カラムパラメーター
|
|
1180
|
+
|
|
1181
|
+
# coderay sql
|
|
1182
|
+
|
|
1183
|
+
CREATE TABLE tags (
|
|
1184
|
+
name VARCHAR(64) PRIMARY KEY
|
|
1185
|
+
) ENGINE=Mroonga DEFAULT CHARSET=utf8mb4;
|
|
1186
|
+
|
|
1187
|
+
CREATE TABLE bugs (
|
|
1188
|
+
tag VARCHAR(64) GROONGA_TYPE='tags'
|
|
1189
|
+
) ENGINE=Mroonga DEFAULT CHARSET=utf8mb4;
|
|
1190
|
+
|
|
1191
|
+
= Mroonga: 3
|
|
1192
|
+
|
|
1193
|
+
MySQL 5.7対応
|
|
1194
|
+
|
|
1195
|
+
= MySQL 5.7対応
|
|
1196
|
+
|
|
1197
|
+
* MySQL 5.7でビルドできる
|
|
1198
|
+
* JSON型対応
|
|
1199
|
+
|
|
1200
|
+
= JSON型
|
|
1201
|
+
|
|
1202
|
+
# coderay sql
|
|
1203
|
+
|
|
1204
|
+
CREATE TABLE logs (
|
|
1205
|
+
record JSON
|
|
1206
|
+
) ENGINE=Mroonga
|
|
1207
|
+
DEFAULT CHARSET=utf8mb4;
|
|
1208
|
+
INSERT INTO logs
|
|
1209
|
+
VALUES ('{"message": "start"}');
|
|
1210
|
+
|
|
1211
|
+
= Mroonga: 4
|
|
1212
|
+
|
|
1213
|
+
MariaDB 10.1\n
|
|
1214
|
+
対応
|
|
1215
|
+
|
|
1216
|
+
= 最新情報:Droonga
|
|
1217
|
+
|
|
1218
|
+
# image
|
|
1219
|
+
# src = images/droonga-logo.svg
|
|
1220
|
+
# relative_width = 100
|
|
1221
|
+
|
|
1222
|
+
(('tag:center'))
|
|
1223
|
+
どゅるんが\n
|
|
1224
|
+
((*D*))istributed ((*Groonga*))\n
|
|
1225
|
+
(('note:分散対応Groonga'))
|
|
1226
|
+
|
|
1227
|
+
= Droonga: 1
|
|
1228
|
+
|
|
1229
|
+
ダウンタイム\n
|
|
1230
|
+
なしの\n
|
|
1231
|
+
ノード追加対応
|
|
1232
|
+
|
|
1233
|
+
= 今年のまとめ
|
|
1234
|
+
|
|
1235
|
+
* Groonga:たくさん改良
|
|
1236
|
+
* Mroonga
|
|
1237
|
+
* 使い勝手改良・最新対応
|
|
1238
|
+
* PGroonga: 今年デビュー
|
|
1239
|
+
* Rroonga:最新対応
|
|
1240
|
+
* Droonga:可用性向上
|
|
1241
|
+
|
|
1242
|
+
= 今後
|
|
1243
|
+
|
|
1244
|
+
= ヒント
|
|
1245
|
+
|
|
1246
|
+
* 実現は保証しない
|
|
1247
|
+
* 実現しようとはするよ!
|
|
1248
|
+
* 実現可能性を高めるには…
|
|
1249
|
+
* 開発に参加\n
|
|
1250
|
+
(('note:コード・ドキュメントを書く・テストする・宣伝する'))
|
|
1251
|
+
* 開発者が開発する時間を増やす\n
|
|
1252
|
+
(('note:他のユーザーをサポート・情報公開・仕事を頼む'))
|
|
1253
|
+
|
|
1254
|
+
= 今後:Groonga
|
|
1255
|
+
|
|
1256
|
+
# image
|
|
1257
|
+
# src = images/groonga-logo.svg
|
|
1258
|
+
# relative_width = 100
|
|
1259
|
+
|
|
1260
|
+
(('tag:center'))
|
|
1261
|
+
ぐるんが
|
|
1262
|
+
|
|
1263
|
+
= Groonga: 1
|
|
1264
|
+
|
|
1265
|
+
(('tag:center'))
|
|
1266
|
+
(('tag:margin-bottom'))
|
|
1267
|
+
カラムストアをもっと活かす
|
|
1268
|
+
|
|
1269
|
+
* シーケンシャルサーチを速く!
|
|
1270
|
+
* ソートを速く!
|
|
1271
|
+
* ドリルダウンを速く!
|
|
1272
|
+
|
|
1273
|
+
(('tag:center'))
|
|
1274
|
+
↓\n
|
|
1275
|
+
grn_ts(ぐるんたす)
|
|
1276
|
+
|
|
1277
|
+
= Groonga: 2
|
|
1278
|
+
|
|
1279
|
+
(('tag:center'))
|
|
1280
|
+
(('tag:margin-bottom'))
|
|
1281
|
+
mrubyをデフォルト有効
|
|
1282
|
+
|
|
1283
|
+
* プラグインをRubyで書ける
|
|
1284
|
+
* 式を書き換えられる
|
|
1285
|
+
* オプティマイザーを書ける
|
|
1286
|
+
|
|
1287
|
+
= Groonga: 3
|
|
1288
|
+
|
|
1289
|
+
(('tag:center'))
|
|
1290
|
+
(('tag:margin-bottom'))
|
|
1291
|
+
プラグインエコシステム
|
|
1292
|
+
|
|
1293
|
+
* プラグイン管理コマンド提供
|
|
1294
|
+
* 例:(({grn plugin install XXX}))
|
|
1295
|
+
* プラグインリポジトリー提供\n
|
|
1296
|
+
(('note:GoのようにGitから直接インストールでもいいかも'))
|
|
1297
|
+
* 対応プラグイン
|
|
1298
|
+
* Rubyで書かれたプラグイン
|
|
1299
|
+
|
|
1300
|
+
= Groonga: 4
|
|
1301
|
+
|
|
1302
|
+
(('tag:center'))
|
|
1303
|
+
(('tag:margin-bottom'))
|
|
1304
|
+
位置指定マッチ対応
|
|
1305
|
+
|
|
1306
|
+
* N番目のトークンならマッチ
|
|
1307
|
+
* 例:1番目のトークンは(({hello}))?
|
|
1308
|
+
* マッチする:(({hello world}))
|
|
1309
|
+
* マッチしない:(({hey! hello world}))
|
|
1310
|
+
|
|
1311
|
+
= 位置指定マッチ応用例1
|
|
1312
|
+
|
|
1313
|
+
(('tag:center'))
|
|
1314
|
+
(('tag:margin-bottom'))
|
|
1315
|
+
正規表現の前方一致検索
|
|
1316
|
+
|
|
1317
|
+
* Groongaでの構文:(({\A}))
|
|
1318
|
+
* 例:(({\Ahello}))
|
|
1319
|
+
* 実装:
|
|
1320
|
+
* 1番目のトークンかチェック
|
|
1321
|
+
|
|
1322
|
+
= 位置指定マッチ応用例2
|
|
1323
|
+
|
|
1324
|
+
(('tag:center'))
|
|
1325
|
+
(('tag:margin-bottom'))
|
|
1326
|
+
ベクターのN番目の要素にマッチ
|
|
1327
|
+
|
|
1328
|
+
# coderay json
|
|
1329
|
+
{
|
|
1330
|
+
"rank": ["Alice", "Bob", "Chris"]
|
|
1331
|
+
}
|
|
1332
|
+
# rank[0] @ "Bob"→マッチしない
|
|
1333
|
+
# rank[1] @ "Bob"→マッチする
|
|
1334
|
+
|
|
1335
|
+
= Groonga: 5
|
|
1336
|
+
|
|
1337
|
+
(('tag:center'))
|
|
1338
|
+
(('tag:margin-bottom'))
|
|
1339
|
+
(({select}))で計算結果での\n
|
|
1340
|
+
ドリルダウン・ソートに対応
|
|
1341
|
+
|
|
1342
|
+
* 例
|
|
1343
|
+
* 元データ:日時(('note:(2015-11-29 13:30)'))
|
|
1344
|
+
* 計算結果:年月日(('note:(2015-11-29)'))
|
|
1345
|
+
* ドリルダウン:計算結果を使用\n
|
|
1346
|
+
(('note:(2015-11-29: 1件、2015-11-30: 2件)'))
|
|
1347
|
+
|
|
1348
|
+
= (({select}))例
|
|
1349
|
+
|
|
1350
|
+
select Logs \
|
|
1351
|
+
--column[access_day].type Time \
|
|
1352
|
+
--column[access_day].source \
|
|
1353
|
+
'time_floor_year(access_time)' \
|
|
1354
|
+
--drilldown access_day
|
|
1355
|
+
|
|
1356
|
+
= Groonga: 6
|
|
1357
|
+
|
|
1358
|
+
(('tag:center'))
|
|
1359
|
+
(('tag:margin-bottom'))
|
|
1360
|
+
JSONでのパラメーター指定\n
|
|
1361
|
+
(('note:(も使えるようにする)'))
|
|
1362
|
+
|
|
1363
|
+
* メリット
|
|
1364
|
+
* プログラムから指定しやすい\n
|
|
1365
|
+
(('note:ことがあるかもしれない'))
|
|
1366
|
+
* デメリット
|
|
1367
|
+
* クエリーログに残らない
|
|
1368
|
+
|
|
1369
|
+
= クエリーストリング
|
|
1370
|
+
|
|
1371
|
+
(('tag:center'))
|
|
1372
|
+
現行
|
|
1373
|
+
|
|
1374
|
+
% curl \
|
|
1375
|
+
'localhost:10041/d/select' \
|
|
1376
|
+
--get \
|
|
1377
|
+
--data-urlencode 'table=users' \
|
|
1378
|
+
--data-urlencode 'limit=100'
|
|
1379
|
+
|
|
1380
|
+
= JSON
|
|
1381
|
+
|
|
1382
|
+
% cat select.json
|
|
1383
|
+
{
|
|
1384
|
+
"table": "users",
|
|
1385
|
+
"limit": "100"
|
|
1386
|
+
}
|
|
1387
|
+
% curl \
|
|
1388
|
+
'localhost:10041/d/select' \
|
|
1389
|
+
--header 'Content-Type: application/json' \
|
|
1390
|
+
--data-binary @select.json
|
|
1391
|
+
|
|
1392
|
+
= Groonga: 7
|
|
1393
|
+
|
|
1394
|
+
(('tag:center'))
|
|
1395
|
+
(('tag:margin-bottom'))
|
|
1396
|
+
ドキュメント改善
|
|
1397
|
+
|
|
1398
|
+
* 未ドキュメントな項目を書く
|
|
1399
|
+
* 古いドキュメントを更新
|
|
1400
|
+
|
|
1401
|
+
= 今後:Mroonga
|
|
1402
|
+
|
|
1403
|
+
# image
|
|
1404
|
+
# src = images/mroonga-logo.svg
|
|
1405
|
+
# relative_width = 100
|
|
1406
|
+
|
|
1407
|
+
(('tag:center'))
|
|
1408
|
+
むるんが\n
|
|
1409
|
+
((*M*))ySQL + G((*roonga*))
|
|
1410
|
+
|
|
1411
|
+
= Mroonga: 1
|
|
1412
|
+
|
|
1413
|
+
(('tag:center'))
|
|
1414
|
+
(('tag:margin-bottom'))
|
|
1415
|
+
ラッパーモードで\n
|
|
1416
|
+
ロールバック対応
|
|
1417
|
+
|
|
1418
|
+
* 現状:ロールバック非対応\n
|
|
1419
|
+
(('note:(変更が残ってしまい検索結果に不整合発生)'))
|
|
1420
|
+
* 今後:コミット時にまとめて更新\n
|
|
1421
|
+
(('note:(ロールバックしても変更が残らない)'))
|
|
1422
|
+
* 現状:トランザクション中に\n
|
|
1423
|
+
更新データを検索可能
|
|
1424
|
+
* 今後:検索不可能
|
|
1425
|
+
|
|
1426
|
+
= Mroonga: 2
|
|
1427
|
+
|
|
1428
|
+
(('tag:center'))
|
|
1429
|
+
(('tag:margin-bottom'))
|
|
1430
|
+
MariaDBで\n
|
|
1431
|
+
テーブルパラメーター対応
|
|
1432
|
+
|
|
1433
|
+
# coderay sql
|
|
1434
|
+
|
|
1435
|
+
CREATE TABLE xxx (
|
|
1436
|
+
) ENGINE=Mroonga
|
|
1437
|
+
COMMENT='ENGINE "InnoDB"'
|
|
1438
|
+
-- ↑を↓と書ける
|
|
1439
|
+
WRAP ENGINE=InnoDB;
|
|
1440
|
+
|
|
1441
|
+
= Mroonga: 3
|
|
1442
|
+
|
|
1443
|
+
(('tag:center'))
|
|
1444
|
+
(('tag:margin-bottom'))
|
|
1445
|
+
generated column対応\n
|
|
1446
|
+
(('note:MySQL 5.7で導入。MariaDBでいうvirtual column。'))
|
|
1447
|
+
|
|
1448
|
+
# coderay sql
|
|
1449
|
+
|
|
1450
|
+
CREATE TABLE users (
|
|
1451
|
+
first_name text,
|
|
1452
|
+
last_name text,
|
|
1453
|
+
full_name text AS
|
|
1454
|
+
(CONCAT_WS(' ', first_name, last_name))
|
|
1455
|
+
STORED
|
|
1456
|
+
) ENGINE=Mroonga;
|
|
1457
|
+
|
|
1458
|
+
= Mroonga: 4
|
|
1459
|
+
|
|
1460
|
+
(('tag:center'))
|
|
1461
|
+
(('tag:margin-bottom'))
|
|
1462
|
+
ネイティブパーテション対応\n
|
|
1463
|
+
(('note:MySQL 5.7で導入。FULLTEXT INDEXを使えるようになる!'))
|
|
1464
|
+
|
|
1465
|
+
# coderay sql
|
|
1466
|
+
|
|
1467
|
+
CREATE TABLE memos (
|
|
1468
|
+
created_time DATETIME,
|
|
1469
|
+
content text,
|
|
1470
|
+
FULLTEXT INDEX (content)
|
|
1471
|
+
) ENGINE=Mroonga
|
|
1472
|
+
PARTITION BY RANGE (TO_DAYS(timestamp)) (
|
|
1473
|
+
-- ...
|
|
1474
|
+
);
|
|
1475
|
+
|
|
1476
|
+
= Mroonga: 5
|
|
1477
|
+
|
|
1478
|
+
(('tag:center'))
|
|
1479
|
+
(('tag:margin-bottom'))
|
|
1480
|
+
JSONの全文検索対応
|
|
1481
|
+
|
|
1482
|
+
# coderay sql
|
|
1483
|
+
|
|
1484
|
+
CREATE TABLE logs (
|
|
1485
|
+
message JSON,
|
|
1486
|
+
FULLTEXT INDEX (message)
|
|
1487
|
+
) ENGINE=Mroonga;
|
|
1488
|
+
SELECT * FROM logs
|
|
1489
|
+
WHERE MATCH(message)
|
|
1490
|
+
AGAINST('*D+ error' IN BOOLEAN MODE);
|
|
1491
|
+
|
|
1492
|
+
= Mroonga: 6
|
|
1493
|
+
|
|
1494
|
+
(('tag:center'))
|
|
1495
|
+
(('tag:margin-bottom'))
|
|
1496
|
+
同義語展開対応
|
|
1497
|
+
|
|
1498
|
+
# coderay sql
|
|
1499
|
+
|
|
1500
|
+
SELECT * FROM memos
|
|
1501
|
+
WHERE MATCH(content)
|
|
1502
|
+
AGAINST(mroonga_expand_query('*D+ 焼き肉')
|
|
1503
|
+
IN BOOLEAN MODE);
|
|
1504
|
+
-- → AGAINST('*D+ 焼き肉 OR 焼肉' IN BOOLEAN MDOE)
|
|
1505
|
+
-- 同義語はMroongaのテーブルにして
|
|
1506
|
+
-- SQLで管理できるようにする
|
|
1507
|
+
|
|
1508
|
+
= Mroonga: 7
|
|
1509
|
+
|
|
1510
|
+
(('tag:center'))
|
|
1511
|
+
(('tag:margin-bottom'))
|
|
1512
|
+
ドキュメント改善
|
|
1513
|
+
|
|
1514
|
+
* Sphinx→GitHub Pages
|
|
1515
|
+
* Sphinx・reSTはオーバースペック
|
|
1516
|
+
* Markdownで十分
|
|
1517
|
+
* typoを見つけても正しく直せない
|
|
1518
|
+
|
|
1519
|
+
= 今後:PGroonga
|
|
1520
|
+
|
|
1521
|
+
# image
|
|
1522
|
+
# src = images/pgroonga-logo.svg
|
|
1523
|
+
# relative_width = 100
|
|
1524
|
+
|
|
1525
|
+
(('tag:center'))
|
|
1526
|
+
ぴーじーるんが\n
|
|
1527
|
+
((*P*))ost((*g*))reSQL + ((*Groonga*))
|
|
1528
|
+
|
|
1529
|
+
= PGroonga: 1
|
|
1530
|
+
|
|
1531
|
+
(('tag:center'))
|
|
1532
|
+
(('tag:margin-bottom'))
|
|
1533
|
+
(({text @@ pgroonga.query}))を導入
|
|
1534
|
+
|
|
1535
|
+
# coderay sql
|
|
1536
|
+
|
|
1537
|
+
SET enable_indexscan = off;
|
|
1538
|
+
SET enable_bitmapscan = off;
|
|
1539
|
+
SELECT * FROM WHERE content @@ '全文検索';
|
|
1540
|
+
-- ↑PostgreSQL組み込みの@@が使われる
|
|
1541
|
+
SELECT * FROM
|
|
1542
|
+
WHERE content @@ '全文検索'::pgroonga.query;
|
|
1543
|
+
-- ↑PGroonga提供の@@が使われる
|
|
1544
|
+
|
|
1545
|
+
= PGroonga: 2
|
|
1546
|
+
|
|
1547
|
+
(('tag:center'))
|
|
1548
|
+
(('tag:margin-bottom * 5'))
|
|
1549
|
+
もっとGroongaを活かす
|
|
1550
|
+
|
|
1551
|
+
# RT
|
|
1552
|
+
delimiter = [|]
|
|
1553
|
+
|
|
1554
|
+
PGroonga | pg_bigm | Groonga
|
|
1555
|
+
|
|
1556
|
+
(('0.646s')) | (('0.556s')) | ((*0.085s*))
|
|
1557
|
+
|
|
1558
|
+
(('note:ヒット数635,792、検索語は2文字'))
|
|
1559
|
+
|
|
1560
|
+
(('tag:center'))
|
|
1561
|
+
生Groongaは1桁速い!\n
|
|
1562
|
+
(('note:詳細:https://github.com/groonga/wikipedia-search/issues/3'))
|
|
1563
|
+
|
|
1564
|
+
= PGroonga: 3
|
|
1565
|
+
|
|
1566
|
+
(('tag:center'))
|
|
1567
|
+
(('tag:margin-bottom'))
|
|
1568
|
+
同義語展開対応
|
|
1569
|
+
|
|
1570
|
+
# coderay sql
|
|
1571
|
+
body @@ pgroonga.expand_query('ネジ')
|
|
1572
|
+
-- ↓
|
|
1573
|
+
body @@ 'ネジ OR ねじ OR ボルト'
|
|
1574
|
+
|
|
1575
|
+
= PGroonga: 4
|
|
1576
|
+
|
|
1577
|
+
(('tag:center'))
|
|
1578
|
+
(('tag:margin-bottom'))
|
|
1579
|
+
ステミング対応
|
|
1580
|
+
|
|
1581
|
+
found/finds→find
|
|
1582
|
+
|
|
1583
|
+
# coderay sql
|
|
1584
|
+
CREATE INDEX index ON entries
|
|
1585
|
+
USING pgroonga (title)
|
|
1586
|
+
WITH (token_filters = 'TokenStem');
|
|
1587
|
+
|
|
1588
|
+
= PGroonga: 5
|
|
1589
|
+
|
|
1590
|
+
(('tag:center'))
|
|
1591
|
+
(('tag:margin-bottom'))
|
|
1592
|
+
重み対応
|
|
1593
|
+
|
|
1594
|
+
# coderay sql
|
|
1595
|
+
-- タイトルのほうが本文より10倍重要
|
|
1596
|
+
body @@ ('title * 10 || body', 'ポスグレ')
|
|
1597
|
+
|
|
1598
|
+
= PGroonga: 6
|
|
1599
|
+
|
|
1600
|
+
(('tag:center'))
|
|
1601
|
+
(('tag:margin-bottom'))
|
|
1602
|
+
複合主キー対応
|
|
1603
|
+
|
|
1604
|
+
# coderay sql
|
|
1605
|
+
CREATE TABLE t (
|
|
1606
|
+
c1 INT,
|
|
1607
|
+
c2 INT,
|
|
1608
|
+
PRIMARY KEY (c1, c2)
|
|
1609
|
+
);
|
|
1610
|
+
CREATE INDEX index ON t
|
|
1611
|
+
USING pgroonga (c1, c2);
|
|
1612
|
+
|
|
1613
|
+
= PGroonga: 7
|
|
1614
|
+
|
|
1615
|
+
(('tag:center'))
|
|
1616
|
+
(('tag:margin-bottom'))
|
|
1617
|
+
(({pg_dump}))の(({WITH}))問題を解消
|
|
1618
|
+
|
|
1619
|
+
# coderay sql
|
|
1620
|
+
CREATE INDEX index ON t
|
|
1621
|
+
USING pgroonga (c)
|
|
1622
|
+
WITH (tokenizer = 'TokenMecab');
|
|
1623
|
+
-- ↓pg_dump: クォートがとれる→小文字に正規化される
|
|
1624
|
+
CREATE INDEX index ON t
|
|
1625
|
+
USING pgroonga (c)
|
|
1626
|
+
WITH (tokenizer = TokenMecab);
|
|
1627
|
+
|
|
1628
|
+
= 今後:Rroonga
|
|
1629
|
+
|
|
1630
|
+
# image
|
|
1631
|
+
# src = images/rroonga-logo.svg
|
|
1632
|
+
# relative_width = 100
|
|
1633
|
+
|
|
1634
|
+
(('tag:center'))
|
|
1635
|
+
るるんが\n
|
|
1636
|
+
((*R*))uby + ((*Groonga*))
|
|
1637
|
+
|
|
1638
|
+
= Rroonga: 1
|
|
1639
|
+
|
|
1640
|
+
(('tag:center'))
|
|
1641
|
+
(('tag:margin-bottom'))
|
|
1642
|
+
ドキュメント改善
|
|
1643
|
+
|
|
1644
|
+
* Textile→Markdown
|
|
1645
|
+
* 英語化
|
|
1646
|
+
* 説明追加(主にコード例)
|
|
1647
|
+
|
|
1648
|
+
= 今後:Droonga
|
|
1649
|
+
|
|
1650
|
+
# image
|
|
1651
|
+
# src = images/droonga-logo.svg
|
|
1652
|
+
# relative_width = 100
|
|
1653
|
+
|
|
1654
|
+
(('tag:center'))
|
|
1655
|
+
どゅるんが\n
|
|
1656
|
+
((*D*))istributed ((*Groonga*))\n
|
|
1657
|
+
(('note:分散対応Groonga'))
|
|
1658
|
+
|
|
1659
|
+
= Droonga: 1
|
|
1660
|
+
|
|
1661
|
+
シャーディング\n
|
|
1662
|
+
対応
|
|
1663
|
+
|
|
1664
|
+
= Groonga族以外
|
|
1665
|
+
|
|
1666
|
+
* キラーアプリが欲しい
|
|
1667
|
+
* 世界規模で認知されたい
|
|
1668
|
+
* Mroonga・PGroongaをきっかけに\n
|
|
1669
|
+
(('note:MroongaはMariaDBにバンドルされている'))
|
|
1670
|
+
* 本を出したい
|
|
1671
|
+
* 初心者向けのやつ
|
|
1672
|
+
|
|
1673
|
+
= まとめ
|
|
1674
|
+
|
|
1675
|
+
* Groonga族は今年も進化した
|
|
1676
|
+
* Groonga族は来年も進化する
|
|
1677
|
+
* 来年はもっと世界規模で\n
|
|
1678
|
+
ユーザーを増やしたい
|
|
1679
|
+
|
|
1680
|
+
= おしらせ1
|
|
1681
|
+
|
|
1682
|
+
* Groongaで学ぶ全文検索\n
|
|
1683
|
+
(('note:↑で検索!'))
|
|
1684
|
+
* 隔週金曜の夜開催
|
|
1685
|
+
* 予習復習なしで時間内で\n
|
|
1686
|
+
効率よく全文検索を学ぶ会
|
|
1687
|
+
* 参加者のレベルは問わない
|
|
1688
|
+
* 内容は毎回参加者に合わせて決める
|
|
1689
|
+
|
|
1690
|
+
全文検索を学びたい方はどうぞ!
|
|
1691
|
+
|
|
1692
|
+
= おしらせ2
|
|
1693
|
+
|
|
1694
|
+
MySQLとPostgreSQLと\n
|
|
1695
|
+
日本語全文検索\n
|
|
1696
|
+
\n
|
|
1697
|
+
来年2月9日(肉の日)\n
|
|
1698
|
+
DMM.comラボにて
|