HAYASHI Kentaro
null+****@clear*****
Fri Sep 28 14:28:09 JST 2012
HAYASHI Kentaro 2012-09-28 14:28:09 +0900 (Fri, 28 Sep 2012) New Revision: c4643af4f18587ebd41393e59b4720e4ba59a79c https://github.com/groonga/groonga.github.com/commit/c4643af4f18587ebd41393e59b4720e4ba59a79c Log: doc ja: add 2.0.7 release entry Added files: ja/_posts/2012-09-29-release.textile Added: ja/_posts/2012-09-29-release.textile (+156 -0) 100644 =================================================================== --- /dev/null +++ ja/_posts/2012-09-29-release.textile 2012-09-28 14:28:09 +0900 (e28e138) @@ -0,0 +1,156 @@ +--- +layout: post.ja +title: groonga 2.0.7リリース +description: groonga 2.0.7がリリースされました! +published: false +--- +h2. groonga 2.0.7リリース + +今日は肉の日ですね。 + +"groonga 2.0.7":/ja/docs/news.html#release-2-0-7 がリリースされました! + +それぞれの環境毎のインストール方法: "インストール":/ja/docs/install.html + +今回のリリースの主なトピックは3つあります。 + +* @groonga-httpd@ でのPOSTによる @load@ コマンドのサポート +* サーバーパッケージ構成と使用ポートの見直し +* @min@ / @max@ 関数のサポート + +h3. @groonga-httpd@ でのPOSTによる @load@ コマンドのサポート + +今回のリリースでは、POSTによる @load@ コマンドの実行をサポートしました。 + +実際の例を以下に示します。 + +サンプルで使うスキーマ定義: + +<pre> + table_create --name Site --flags TABLE_HASH_KEY --key_type ShortText + column_create --table Site --name title --type ShortText +</pre> + +http://localhost:10041/にアクセスするとブラウザベースの管理ツールを使って上記スキーマ定義のSiteテーブルおよびtitleカラムを簡単に作成することができます。 + +テーブルとカラムを作り終えたら、次にSiteテーブルへと登録しておきたいレコードをJSON形式で用意します。(例としてファイル名はpostbody.txtとします。) + +<pre> + [ + {"_key": "site1", "title":"Web site1 title"} + ] +</pre> + +登録データが準備できたので、curlコマンドを使ってPOSTリクエストをサーバーへと投げてみます。 + +<pre> + % curl -X POST 'http://localhost:10041/d/load?table=Site' --verbose -H 'Content-Type: application/json' -d****@postb***** +</pre> + +実行するとpostbody.txtのデータが @load@ コマンドにより登録できます。 + +h3. サーバーパッケージ構成と使用ポートの見直し + +今回のリリースではサーバーパッケージ構成と使用ポートの見直しを行いました。 + +従来サーバー用途では以下のHTTPサーバーパッケージのみ提供していました。 + +* groonga-server (HTTPサーバー) +* groonga-httpd (HTTPサーバー) + +GQTPプロトコルで使うには不便ですし、デフォルトで使用するポートもGQTPとHTTPで使用ポートがどちらも10041番ポートと衝突していました。 + +そこで、groonga-serverパッケージを分割し、プロトコルごとで異なるパッケージを提供するようにしました。 +使用するポート番号についても別のポート番号を割りあてるようにしました。(HTTPは従来通り10041番ポート。GQTPを10043番ポートに割り当て変更。) + +* groonga-server-http (HTTPサーバー 10041ポート) +* groonga-server-gqtp (GQTPサーバー 10043ポート) + +<pre> +注: groonga-server-httpパッケージとgroonga-httpdパッケージはいずれかのみインストールすることができます。 +</pre> + +h3. @min@ / @max@ 関数のサポート + +今回のリリースではminおよびmax関数をサポートしました。 + +* min関数は与えられた引数のうち最小のものを返し、 +* max関数は与えられた引数のうち最大のものを返します。 + +これら関数のサポートにより、検索結果が条件に合致する度合いを示すスコアが極端に高かったり、もしくは低くなってしまった場合に検索結果を調整することができるようになります。 + +具体例をmin関数を使ったサンプルで示します。 + +サンプルで使うスキーマ定義: + +<pre> + table_create --name Site --flags TABLE_HASH_KEY --key_type ShortText + column_create --table Site --name title --type ShortText + column_create --table Site --name point --type Int8 + + 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 +</pre> + +サンプルで使うためのデータ登録: + +<pre> + load --table Site + [ + {"_key":"http://example.org/","title":"This is test record 1!","point":1}, + {"_key":"http://example.net/","title":"test record 2.","point":2}, + {"_key":"http://example.com/","title":"test test record three.","point":3}, + {"_key":"http://example.net/afr","title":"test record four.", "point":4}, + {"_key":"http://example.org/aba","title":"test test test record five.","point":5}, + {"_key":"http://example.com/rab","title":"test test test test record six.","point":0}, + {"_key":"http://example.net/atv","title":"test test test record seven.","point":7}, + {"_key":"http://example.org/gat","title":"test test record eight.","point":8}, + {"_key":"http://example.com/vdw","title":"test test record nine.","point":9}, + ] +</pre> + +例えば、指定した語句(test)をカラムtitleに含むテキストの全文検索を行うことを考えます。個々のデータには重要度(point)があらかじめ与えられているとします。 + +単純に指定した語句(test)にマッチするものが多いデータをソート(スコアが同じなら重要度で降順)して取得するならば以下のクエリで取得できます。 + +<pre> + % select --table Site --query title:@test --output_columns _id,_score,title,point --sortby -_score,-point + + ["_id","UInt32"],["_score","Int32"],["title","ShortText"],["point","Int8"] + [6,4,"test test test test record six.",0], + [7,3,"test test test record seven.",7], + [5,3,"test test test record five.",5], + [9,2,"test test record nine.",9], + [8,2,"test test record eight.",8], + [3,2,"test test record three.",3], + [4,1,"test record four.",4], + [2,1,"test record 2.",2], + [1,1,"This is test record 1!",1] +</pre> + +ただし、これだと重要度が低い"test test test test record six."がトップに来ます。マッチするのは重視したいけれども、それほど高いスコアを与えると望ましい結果にならないときに調整するのに使えるのが、min関数です。 + +groongaではスコアを_scoreカラムに保持しています。そこで、min関数を使って極端に高いスコアにならないようにします。 + +<pre> + % select --table Site --query title:@test --output_columns _id,_score,title,point \ + --scorer '_score = min(_score, 3) --sortby -_score,-point + + ["_id","UInt32"],["_score","Int32"],["title","ShortText"],["point","Int8"] + [7,3,"test test test record seven.",7], + [5,3,"test test test record five.",5], + [6,3,"test test test test record six.",0], + [9,2,"test test record nine.",9], + [8,2,"test test record eight.",8], + [3,2,"test test record three.",3], + [4,1,"test record four.",4], + [2,1,"test record 2.",2],[1,1,"This is test record 1!",1] +</pre> + +すると、マッチしているものを重視しつつ、設定済みの重要度も考慮した結果を得ることができるようになります。 + +h3. さいごに + +2.0.6からの詳細な変更点は "2.0.7リリース 2012/09/29":/ja/docs/news.html#release-2-0-7 を確認してください。 + +それでは、groongaでガンガン検索してください! -------------- next part -------------- HTML����������������������������... Descargar