Navigation Menu

Skip to content

Commit

Permalink
blog ja: add 3.0.5 release entry
Browse files Browse the repository at this point in the history
  • Loading branch information
kenhys committed Jun 28, 2013
1 parent a6e1886 commit 2967cff
Showing 1 changed file with 143 additions and 0 deletions.
143 changes: 143 additions & 0 deletions ja/_posts/2013-06-29-release.textile
@@ -0,0 +1,143 @@
---
layout: post.ja
title: groonga 3.0.5リリース
description: groonga 3.0.5をリリースしました!
published: false
---

今日は肉の日ですね。

h2. groonga 3.0.5リリース

"groonga 3.0.5":/ja/docs/news.html#release-3-0-5 をリリースしました!

それぞれの環境毎のインストール方法: "インストール":/ja/docs/install.html


はじめに、利用事例の記事を書いてくれる人募集のお知らせです。(再度)

これまでも、groonga.orgにて "利用事例":http://groonga.org/ja/users/ を紹介してきましたが、それとは別に、 "gihyo.jp":http://gihyo.jp/ にてgroonga関連の記事の連載を "隔週連載groonga":http://gihyo.jp/dev/clip/01/groonga としてはじめました。

まだgroongaを知らない人にもWebの連載記事を通じて知ってもらいたいというのが動機です。現在第6回まで公開しています。先月は第4回までだったので記事が二本新たに追加されました。


* "第1回 全文検索エンジンgroongaを紹介します!":http://gihyo.jp/dev/clip/01/groonga/0001
* "第2回 groongaをRuby On Railsでも使ってみた ~chikamap.comの事例から":http://gihyo.jp/dev/clip/01/groonga/0002
* "第3回 すべてのMySQLユーザに高速な全文検索機能を! - mroongaの紹介":http://gihyo.jp/dev/clip/01/groonga/0003
* "第4回 rroongaを使ったソースコード検索エンジンMilkode":http://gihyo.jp/dev/clip/01/groonga/0004
* "第5回 Rubyでサーバ要らずの高速全文検索! - rroongaの紹介":http://gihyo.jp/dev/clip/01/groonga/0005
* "第6回 [実録] MySQL向け全文検索エンジン「Tritonn」から「mroonga」への移行ガイド(1)":http://gihyo.jp/dev/clip/01/groonga/0006

利用事例がつきたら終了なので、実際に使っているユーザーのみなさんに利用事例を書いてもらえたらいいなぁと思っています!
詳細は "groonga普及のための協力のお願い":http://sourceforge.jp/projects/groonga/lists/archive/dev/2013-February/001186.html を参照してください。

h3. output_columnsでシングルクォートした文字列をサポート

今回のリリースではoutput_columnsでシングルクォートした文字列をサポートしました。

groonga 3.0.2から、 @--output_columns@ で複雑な文字列の連結をサポートしました。これは例えば、titleというカラムがあるとして、 @'"<" + title + ">"'@ などとすると @"<(ここにtitleカラムの内容)>"@ というようにカラムの内容をちょっと加工して出力するという用途に使える機能です。

ただし、シングルクォートをサポートしていなかったので、クォートではまることがありました。

以下の例で、今回のリリースからできるようになった記述を紹介します。

<pre>
table_create Entries TABLE_NO_KEY
column_create Entries title COLUMN_SCALAR ShortText

load --table Entries
[
{"title": "Single quote and double quote"}
]
</pre>

3.0.4までだと @"<(ここにtitleカラムの内容)>"@ というのを実現するには以下の方法がありました。

<pre>
select Entries --output_columns '_id, "<" + title + ">"' --command_version 2
select Entries --output_columns "_id, \"<\" + title + \">\"" --command_version 2
</pre>

今回のリリースではシングルクォートをサポートしたので以下のように書けるようになります。

<pre>
select Entries --output_columns "_id, '<' + title + '>'" --command_version 2
</pre>

また、3.0.4では処理できなかった(結果が空になる)、以下のようなシングルクォートやダブルクウォートを含む場合も正しく処理できるようになりました。

<pre>
# <"(titleカラムの内容)">
select Entries --output_columns "_id, '<\"' + title + '\">'" --command_version 2
#=> [1,"<\"Single quote and double quote\">"]

# <'(titleカラムの内容)'>
select Entries --output_columns "_id, '<\\'' + title + '\\'>'" --command_version 2
#=> [1,"<'Single quote and double quote'>"]
</pre>

h3. html_untag関数のサポート

今回のリリースではHTMLタグを除去するための "html_untag関数":http://groonga.org/ja/docs/reference/functions/html_untag を実験的にサポートしました。

例えば、Webサイトのスクレイピング結果をそのままgroongaデータベースに保存しているような場合を考えてみます。

以下のようなスキーマにスクレイピング結果を格納しているとしましょう。

<pre>
table_create WebClips TABLE_NO_KEY
column_create WebClips url COLUMN_SCALAR ShortText
column_create WebClips content COLUMN_SCALAR ShortText
column_create WebClips tag COLUMN_VECTOR ShortText
</pre>

サンプルデータを以下のようにして投入します。

<pre>
load --table WebClips
[
{"_key": 1, "url": "http://groonga.org", "tag": ["groonga"], "content": "groonga is fast"},
{"_key": 2, "url": "http://mroonga.org", "tag": ["mroonga"], "content": "mroonga is fast"},
]
</pre>

html_untagには対象となるカラムを指定します。今回はcontentカラムからHTMLタグを除去した結果が欲しいので、 @html_untag(content)@ となります。実行してみましょう。

<pre>
select WebClips --output_columns "html_untag(content)" --command_version 2
</pre>

結果は以下のようになります。

<pre>
[[2],
[
["html_untag", "null"]
],
["groonga is fast"],
["mroonga is fast"]
]
</pre>

class属性つきのspanタグが除去されているのがわかります。

この関数を使うときには @--command_version 2@ を必ず指定してください。指定しないと意図通りの結果を得られません。

html_untagが導入された背景にはスクレイピングした結果をgroongaのデータベースへと保存した状態で検索したいというのがあります。
ただしそのままではタグが邪魔なので、タグを除去するhtml_untagをサポートしました。
html_untagは単体で使って嬉しいというよりも、snippet_htmlと組み合わせることを(将来的に)想定しています。

具体的には検索結果からHTMLを除去し、ハイライトしたい部分だけsnippet_htmlで加工するというのがあります。

<pre>
元のHTML - html_untag -> テキスト - snippet_html -> 必要な部分だけタグ付け
</pre>

まだ、html_untagの結果をsnippet_htmlでそのまま処理することはできませんが、将来的には対応を予定しています。


h3. さいごに

3.0.4からの詳細な変更点は "3.0.5リリース 2013/06/29":/ja/docs/news.html#release-3-0-5 を確認してください。

それでは、groongaでガンガン検索してください!

0 comments on commit 2967cff

Please sign in to comment.