Yoji Shidara
null+****@clear*****
Mon Feb 17 16:36:15 JST 2014
Yoji Shidara 2014-02-17 16:36:15 +0900 (Mon, 17 Feb 2014) New Revision: c2ddbf847546f714741a0166ee4a104a30555145 https://github.com/droonga/droonga.org/commit/c2ddbf847546f714741a0166ee4a104a30555145 Merged 8df85df: Merge branch 'tutorial-with-droonga-request' into gh-pages Message: ja: Follow upstream update Added files: _po/ja/tutorial/plugin-development/handler/index.po ja/tutorial/plugin-development/handler/index.md Modified files: _po/ja/tutorial/basic/index.po _po/ja/tutorial/plugin-development/adapter/index.po ja/tutorial/basic/index.md ja/tutorial/plugin-development/adapter/index.md Modified: _po/ja/tutorial/basic/index.po (+782 -155) =================================================================== --- _po/ja/tutorial/basic/index.po 2014-02-17 16:32:06 +0900 (a368877) +++ _po/ja/tutorial/basic/index.po 2014-02-17 16:36:15 +0900 (3426849) @@ -202,10 +202,10 @@ msgstr "" "Droonga Engine は、データベースを保持し、実際の検索を担当する部分です。\n" "このセクションでは、 fluent-plugin-droonga をインストールし、検索対象となるデータを準備します。" -msgid "### Install a fluent-plugin-droonga" -msgstr "### fluent-plugin-droonga をインストールする" +msgid "### Install a fluent-plugin-droonga and droonga-client" +msgstr "### fluent-plugin-droongaとdroonga-clientをインストールする" -msgid " # gem install fluent-plugin-droonga" +msgid " # gem install fluent-plugin-droonga droonga-client" msgstr "" msgid "" @@ -388,167 +388,794 @@ msgid "ddl.jsons:" msgstr "" msgid "" -" {\"id\":\"ddl:0\",\"dataset\":\"Starbucks\",\"type\":\"table_create\",\"replyTo\":\"local" -"host:24224/output\",\"body\":{\"name\":\"Store\",\"flags\":\"TABLE_HASH_KEY\",\"key_type\":" -"\"ShortText\"}}\n" -" {\"id\":\"ddl:1\",\"dataset\":\"Starbucks\",\"type\":\"column_create\",\"replyTo\":\"loca" -"lhost:24224/output\",\"body\":{\"table\":\"Store\",\"name\":\"location\",\"flags\":\"COLUMN_" -"SCALAR\",\"type\":\"WGS84GeoPoint\"}}\n" -" {\"id\":\"ddl:2\",\"dataset\":\"Starbucks\",\"type\":\"table_create\",\"replyTo\":\"local" -"host:24224/output\",\"body\":{\"name\":\"Location\",\"flags\":\"TABLE_PAT_KEY\",\"key_type" -"\":\"WGS84GeoPoint\"}}\n" -" {\"id\":\"ddl:3\",\"dataset\":\"Starbucks\",\"type\":\"column_create\",\"replyTo\":\"loca" -"lhost:24224/output\",\"body\":{\"table\":\"Location\",\"name\":\"store\",\"flags\":\"COLUMN_" -"INDEX\",\"type\":\"Store\",\"source\":\"location\"}}\n" -" {\"id\":\"ddl:4\",\"dataset\":\"Starbucks\",\"type\":\"table_create\",\"replyTo\":\"local" -"host:24224/output\",\"body\":{\"name\":\"Term\",\"flags\":\"TABLE_PAT_KEY\",\"key_type\":\"S" -"hortText\",\"default_tokenizer\":\"TokenBigram\",\"normalizer\":\"NormalizerAuto\"}}\n" -" {\"id\":\"ddl:5\",\"dataset\":\"Starbucks\",\"type\":\"column_create\",\"replyTo\":\"loca" -"lhost:24224/output\",\"body\":{\"table\":\"Term\",\"name\":\"stores__key\",\"flags\":\"COLUM" -"N_INDEX|WITH_POSITION\",\"type\":\"Store\",\"source\":\"_key\"}}" +"~~~\n" +"{\"dataset\":\"Starbucks\",\"type\":\"table_create\",\"body\":{\"name\":\"Store\",\"flags\":\"T" +"ABLE_HASH_KEY\",\"key_type\":\"ShortText\"}}\n" +"{\"dataset\":\"Starbucks\",\"type\":\"column_create\",\"body\":{\"table\":\"Store\",\"name\":\"" +"location\",\"flags\":\"COLUMN_SCALAR\",\"type\":\"WGS84GeoPoint\"}}\n" +"{\"dataset\":\"Starbucks\",\"type\":\"table_create\",\"body\":{\"name\":\"Location\",\"flags\"" +":\"TABLE_PAT_KEY\",\"key_type\":\"WGS84GeoPoint\"}}\n" +"{\"dataset\":\"Starbucks\",\"type\":\"column_create\",\"body\":{\"table\":\"Location\",\"name" +"\":\"store\",\"flags\":\"COLUMN_INDEX\",\"type\":\"Store\",\"source\":\"location\"}}\n" +"{\"dataset\":\"Starbucks\",\"type\":\"table_create\",\"body\":{\"name\":\"Term\",\"flags\":\"TA" +"BLE_PAT_KEY\",\"key_type\":\"ShortText\",\"default_tokenizer\":\"TokenBigram\",\"normali" +"zer\":\"NormalizerAuto\"}}\n" +"{\"dataset\":\"Starbucks\",\"type\":\"column_create\",\"body\":{\"table\":\"Term\",\"name\":\"s" +"tores__key\",\"flags\":\"COLUMN_INDEX|WITH_POSITION\",\"type\":\"Store\",\"source\":\"_key" +"\"}}\n" +"~~~" msgstr "" msgid "stores.jsons:" msgstr "" msgid "" -" {\"id\":\"stores:0\",\"replyTo\":\"localhost:24224/output\",\"dataset\":\"Starbucks\"," -"\"type\":\"add\",\"body\":{\"table\":\"Store\",\"key\":\"1st Avenue & 75th St. - New York N" -"Y (W)\",\"values\":{\"location\":\"40.770262,-73.954798\"}}}\n" -" {\"id\":\"stores:1\",\"replyTo\":\"localhost:24224/output\",\"dataset\":\"Starbucks\"," -"\"type\":\"add\",\"body\":{\"table\":\"Store\",\"key\":\"76th & Second - New York NY (W)\"," -"\"values\":{\"location\":\"40.771056,-73.956757\"}}}\n" -" {\"id\":\"stores:2\",\"replyTo\":\"localhost:24224/output\",\"dataset\":\"Starbucks\"," -"\"type\":\"add\",\"body\":{\"table\":\"Store\",\"key\":\"2nd Ave. & 9th Street - New York N" -"Y\",\"values\":{\"location\":\"40.729445,-73.987471\"}}}\n" -" {\"id\":\"stores:3\",\"replyTo\":\"localhost:24224/output\",\"dataset\":\"Starbucks\"," -"\"type\":\"add\",\"body\":{\"table\":\"Store\",\"key\":\"15th & Third - New York NY (W)\",\"" -"values\":{\"location\":\"40.733946,-73.9867\"}}}\n" -" {\"id\":\"stores:4\",\"replyTo\":\"localhost:24224/output\",\"dataset\":\"Starbucks\"," -"\"type\":\"add\",\"body\":{\"table\":\"Store\",\"key\":\"41st and Broadway - New York NY (" -"W)\",\"values\":{\"location\":\"40.755111,-73.986225\"}}}\n" -" {\"id\":\"stores:5\",\"replyTo\":\"localhost:24224/output\",\"dataset\":\"Starbucks\"," -"\"type\":\"add\",\"body\":{\"table\":\"Store\",\"key\":\"84th & Third Ave - New York NY (W" -")\",\"values\":{\"location\":\"40.777485,-73.954979\"}}}\n" -" {\"id\":\"stores:6\",\"replyTo\":\"localhost:24224/output\",\"dataset\":\"Starbucks\"," -"\"type\":\"add\",\"body\":{\"table\":\"Store\",\"key\":\"150 E. 42nd Street - New York NY " -"(W)\",\"values\":{\"location\":\"40.750784,-73.975582\"}}}\n" -" {\"id\":\"stores:7\",\"replyTo\":\"localhost:24224/output\",\"dataset\":\"Starbucks\"," -"\"type\":\"add\",\"body\":{\"table\":\"Store\",\"key\":\"West 43rd and Broadway - New York " -"NY (W)\",\"values\":{\"location\":\"40.756197,-73.985624\"}}}\n" -" {\"id\":\"stores:8\",\"replyTo\":\"localhost:24224/output\",\"dataset\":\"Starbucks\"," -"\"type\":\"add\",\"body\":{\"table\":\"Store\",\"key\":\"Macy's 35th Street Balcony - New Y" -"ork NY\",\"values\":{\"location\":\"40.750703,-73.989787\"}}}\n" -" {\"id\":\"stores:9\",\"replyTo\":\"localhost:24224/output\",\"dataset\":\"Starbucks\"," -"\"type\":\"add\",\"body\":{\"table\":\"Store\",\"key\":\"Macy's 6th Floor - Herald Square -" -" New York NY (W)\",\"values\":{\"location\":\"40.750703,-73.989787\"}}}\n" -" {\"id\":\"stores:10\",\"replyTo\":\"localhost:24224/output\",\"dataset\":\"Starbucks\"" -",\"type\":\"add\",\"body\":{\"table\":\"Store\",\"key\":\"Herald Square- Macy's - New York " -"NY\",\"values\":{\"location\":\"40.750703,-73.989787\"}}}\n" -" {\"id\":\"stores:11\",\"replyTo\":\"localhost:24224/output\",\"dataset\":\"Starbucks\"" -",\"type\":\"add\",\"body\":{\"table\":\"Store\",\"key\":\"Macy's 5th Floor - Herald Square " -"- New York NY (W)\",\"values\":{\"location\":\"40.750703,-73.989787\"}}}\n" -" {\"id\":\"stores:12\",\"replyTo\":\"localhost:24224/output\",\"dataset\":\"Starbucks\"" -",\"type\":\"add\",\"body\":{\"table\":\"Store\",\"key\":\"80th & York - New York NY (W)\",\"" -"values\":{\"location\":\"40.772204,-73.949862\"}}}\n" -" {\"id\":\"stores:13\",\"replyTo\":\"localhost:24224/output\",\"dataset\":\"Starbucks\"" -",\"type\":\"add\",\"body\":{\"table\":\"Store\",\"key\":\"Columbus @ 67th - New York NY (W" -")\",\"values\":{\"location\":\"40.774009,-73.981472\"}}}\n" -" {\"id\":\"stores:14\",\"replyTo\":\"localhost:24224/output\",\"dataset\":\"Starbucks\"" -",\"type\":\"add\",\"body\":{\"table\":\"Store\",\"key\":\"45th & Broadway - New York NY (W" -")\",\"values\":{\"location\":\"40.75766,-73.985719\"}}}\n" -" {\"id\":\"stores:15\",\"replyTo\":\"localhost:24224/output\",\"dataset\":\"Starbucks\"" -",\"type\":\"add\",\"body\":{\"table\":\"Store\",\"key\":\"Marriott Marquis - Lobby - New Yo" -"rk NY\",\"values\":{\"location\":\"40.759123,-73.984927\"}}}\n" -" {\"id\":\"stores:16\",\"replyTo\":\"localhost:24224/output\",\"dataset\":\"Starbucks\"" -",\"type\":\"add\",\"body\":{\"table\":\"Store\",\"key\":\"Second @ 81st - New York NY (W)\"" -",\"values\":{\"location\":\"40.77466,-73.954447\"}}}\n" -" {\"id\":\"stores:17\",\"replyTo\":\"localhost:24224/output\",\"dataset\":\"Starbucks\"" -",\"type\":\"add\",\"body\":{\"table\":\"Store\",\"key\":\"52nd & Seventh - New York NY (W)" -"\",\"values\":{\"location\":\"40.761829,-73.981141\"}}}\n" -" {\"id\":\"stores:18\",\"replyTo\":\"localhost:24224/output\",\"dataset\":\"Starbucks\"" -",\"type\":\"add\",\"body\":{\"table\":\"Store\",\"key\":\"1585 Broadway (47th) - New York N" -"Y (W)\",\"values\":{\"location\":\"40.759806,-73.985066\"}}}\n" -" {\"id\":\"stores:19\",\"replyTo\":\"localhost:24224/output\",\"dataset\":\"Starbucks\"" -",\"type\":\"add\",\"body\":{\"table\":\"Store\",\"key\":\"85th & First - New York NY (W)\"," -"\"values\":{\"location\":\"40.776101,-73.949971\"}}}\n" -" {\"id\":\"stores:20\",\"replyTo\":\"localhost:24224/output\",\"dataset\":\"Starbucks\"" -",\"type\":\"add\",\"body\":{\"table\":\"Store\",\"key\":\"92nd & 3rd - New York NY (W)\",\"v" -"alues\":{\"location\":\"40.782606,-73.951235\"}}}\n" -" {\"id\":\"stores:21\",\"replyTo\":\"localhost:24224/output\",\"dataset\":\"Starbucks\"" -",\"type\":\"add\",\"body\":{\"table\":\"Store\",\"key\":\"165 Broadway - 1 Liberty - New Yo" -"rk NY (W)\",\"values\":{\"location\":\"40.709727,-74.011395\"}}}\n" -" {\"id\":\"stores:22\",\"replyTo\":\"localhost:24224/output\",\"dataset\":\"Starbucks\"" -",\"type\":\"add\",\"body\":{\"table\":\"Store\",\"key\":\"1656 Broadway - New York NY (W)\"" -",\"values\":{\"location\":\"40.762434,-73.983364\"}}}\n" -" {\"id\":\"stores:23\",\"replyTo\":\"localhost:24224/output\",\"dataset\":\"Starbucks\"" -",\"type\":\"add\",\"body\":{\"table\":\"Store\",\"key\":\"54th & Broadway - New York NY (W" -")\",\"values\":{\"location\":\"40.764275,-73.982361\"}}}\n" -" {\"id\":\"stores:24\",\"replyTo\":\"localhost:24224/output\",\"dataset\":\"Starbucks\"" -",\"type\":\"add\",\"body\":{\"table\":\"Store\",\"key\":\"Limited Brands-NYC - New York NY\"" -",\"values\":{\"location\":\"40.765219,-73.982025\"}}}\n" -" {\"id\":\"stores:25\",\"replyTo\":\"localhost:24224/output\",\"dataset\":\"Starbucks\"" -",\"type\":\"add\",\"body\":{\"table\":\"Store\",\"key\":\"19th & 8th - New York NY (W)\",\"v" -"alues\":{\"location\":\"40.743218,-74.000605\"}}}\n" -" {\"id\":\"stores:26\",\"replyTo\":\"localhost:24224/output\",\"dataset\":\"Starbucks\"" -",\"type\":\"add\",\"body\":{\"table\":\"Store\",\"key\":\"60th & Broadway-II - New York NY " -" (W)\",\"values\":{\"location\":\"40.769196,-73.982576\"}}}\n" -" {\"id\":\"stores:27\",\"replyTo\":\"localhost:24224/output\",\"dataset\":\"Starbucks\"" -",\"type\":\"add\",\"body\":{\"table\":\"Store\",\"key\":\"63rd & Broadway - New York NY (W" -")\",\"values\":{\"location\":\"40.771376,-73.982709\"}}}\n" -" {\"id\":\"stores:28\",\"replyTo\":\"localhost:24224/output\",\"dataset\":\"Starbucks\"" -",\"type\":\"add\",\"body\":{\"table\":\"Store\",\"key\":\"195 Broadway - New York NY (W)\"," -"\"values\":{\"location\":\"40.710703,-74.009485\"}}}\n" -" {\"id\":\"stores:29\",\"replyTo\":\"localhost:24224/output\",\"dataset\":\"Starbucks\"" -",\"type\":\"add\",\"body\":{\"table\":\"Store\",\"key\":\"2 Broadway - New York NY (W)\",\"v" -"alues\":{\"location\":\"40.704538,-74.01324\"}}}\n" -" {\"id\":\"stores:30\",\"replyTo\":\"localhost:24224/output\",\"dataset\":\"Starbucks\"" -",\"type\":\"add\",\"body\":{\"table\":\"Store\",\"key\":\"2 Columbus Ave. - New York NY (W" -")\",\"values\":{\"location\":\"40.769262,-73.984764\"}}}\n" -" {\"id\":\"stores:31\",\"replyTo\":\"localhost:24224/output\",\"dataset\":\"Starbucks\"" -",\"type\":\"add\",\"body\":{\"table\":\"Store\",\"key\":\"NY Plaza - New York NY (W)\",\"val" -"ues\":{\"location\":\"40.702802,-74.012784\"}}}\n" -" {\"id\":\"stores:32\",\"replyTo\":\"localhost:24224/output\",\"dataset\":\"Starbucks\"" -",\"type\":\"add\",\"body\":{\"table\":\"Store\",\"key\":\"36th and Madison - New York NY (" -"W)\",\"values\":{\"location\":\"40.748917,-73.982683\"}}}\n" -" {\"id\":\"stores:33\",\"replyTo\":\"localhost:24224/output\",\"dataset\":\"Starbucks\"" -",\"type\":\"add\",\"body\":{\"table\":\"Store\",\"key\":\"125th St. btwn Adam Clayton & FDB" -" - New York NY\",\"values\":{\"location\":\"40.808952,-73.948229\"}}}\n" -" {\"id\":\"stores:34\",\"replyTo\":\"localhost:24224/output\",\"dataset\":\"Starbucks\"" -",\"type\":\"add\",\"body\":{\"table\":\"Store\",\"key\":\"70th & Broadway - New York NY (W" -")\",\"values\":{\"location\":\"40.777463,-73.982237\"}}}\n" -" {\"id\":\"stores:35\",\"replyTo\":\"localhost:24224/output\",\"dataset\":\"Starbucks\"" -",\"type\":\"add\",\"body\":{\"table\":\"Store\",\"key\":\"2138 Broadway - New York NY (W)\"" -",\"values\":{\"location\":\"40.781078,-73.981167\"}}}\n" -" {\"id\":\"stores:36\",\"replyTo\":\"localhost:24224/output\",\"dataset\":\"Starbucks\"" -",\"type\":\"add\",\"body\":{\"table\":\"Store\",\"key\":\"118th & Frederick Douglas Blvd. -" -" New York NY (W)\",\"values\":{\"location\":\"40.806176,-73.954109\"}}}\n" -" {\"id\":\"stores:37\",\"replyTo\":\"localhost:24224/output\",\"dataset\":\"Starbucks\"" -",\"type\":\"add\",\"body\":{\"table\":\"Store\",\"key\":\"42nd & Second - New York NY (W)\"" -",\"values\":{\"location\":\"40.750069,-73.973393\"}}}\n" -" {\"id\":\"stores:38\",\"replyTo\":\"localhost:24224/output\",\"dataset\":\"Starbucks\"" -",\"type\":\"add\",\"body\":{\"table\":\"Store\",\"key\":\"Broadway @ 81st - New York NY (W" -")\",\"values\":{\"location\":\"40.784972,-73.978987\"}}}\n" -" {\"id\":\"stores:39\",\"replyTo\":\"localhost:24224/output\",\"dataset\":\"Starbucks\"" -",\"type\":\"add\",\"body\":{\"table\":\"Store\",\"key\":\"Fashion Inst of Technology - New " -"York NY\",\"values\":{\"location\":\"40.746948,-73.994557\"}}}" -msgstr "" - -msgid "Open another terminal and send those two jsons `ddl.jsons` and `stores.jsons` " -msgstr "別の端末を開き、以下のようにして `ddl.jsons` と `stores.jsons` を投入します:" - -msgid "" -" # fluent-cat starbucks.message < ddl.jsons\n" -" # fluent-cat starbucks.message < stores.jsons" -msgstr "" - -msgid "" -"Now a Droonga engine for searching Starbucks stores database is ready.\n" +"~~~\n" +"{\"dataset\":\"Starbucks\",\"type\":\"add\",\"body\":{\"table\":\"Store\",\"key\":\"1st Avenue " +"& 75th St. - New York NY (W)\",\"values\":{\"location\":\"40.770262,-73.954798\"}}}\n" +"{\"dataset\":\"Starbucks\",\"type\":\"add\",\"body\":{\"table\":\"Store\",\"key\":\"76th & Seco" +"nd - New York NY (W)\",\"values\":{\"location\":\"40.771056,-73.956757\"}}}\n" +"{\"dataset\":\"Starbucks\",\"type\":\"add\",\"body\":{\"table\":\"Store\",\"key\":\"2nd Ave. & " +"9th Street - New York NY\",\"values\":{\"location\":\"40.729445,-73.987471\"}}}\n" +"{\"dataset\":\"Starbucks\",\"type\":\"add\",\"body\":{\"table\":\"Store\",\"key\":\"15th & Thir" +"d - New York NY (W)\",\"values\":{\"location\":\"40.733946,-73.9867\"}}}\n" +"{\"dataset\":\"Starbucks\",\"type\":\"add\",\"body\":{\"table\":\"Store\",\"key\":\"41st and Br" +"oadway - New York NY (W)\",\"values\":{\"location\":\"40.755111,-73.986225\"}}}\n" +"{\"dataset\":\"Starbucks\",\"type\":\"add\",\"body\":{\"table\":\"Store\",\"key\":\"84th & Thir" +"d Ave - New York NY (W)\",\"values\":{\"location\":\"40.777485,-73.954979\"}}}\n" +"{\"dataset\":\"Starbucks\",\"type\":\"add\",\"body\":{\"table\":\"Store\",\"key\":\"150 E. 42nd" +" Street - New York NY (W)\",\"values\":{\"location\":\"40.750784,-73.975582\"}}}\n" +"{\"dataset\":\"Starbucks\",\"type\":\"add\",\"body\":{\"table\":\"Store\",\"key\":\"West 43rd a" +"nd Broadway - New York NY (W)\",\"values\":{\"location\":\"40.756197,-73.985624\"}}}" +"\n" +"{\"dataset\":\"Starbucks\",\"type\":\"add\",\"body\":{\"table\":\"Store\",\"key\":\"Macy's 35th" +" Street Balcony - New York NY\",\"values\":{\"location\":\"40.750703,-73.989787\"}}}\n" +"{\"dataset\":\"Starbucks\",\"type\":\"add\",\"body\":{\"table\":\"Store\",\"key\":\"Macy's 6th " +"Floor - Herald Square - New York NY (W)\",\"values\":{\"location\":\"40.750703,-73." +"989787\"}}}\n" +"{\"dataset\":\"Starbucks\",\"type\":\"add\",\"body\":{\"table\":\"Store\",\"key\":\"Herald Squa" +"re- Macy's - New York NY\",\"values\":{\"location\":\"40.750703,-73.989787\"}}}\n" +"{\"dataset\":\"Starbucks\",\"type\":\"add\",\"body\":{\"table\":\"Store\",\"key\":\"Macy's 5th " +"Floor - Herald Square - New York NY (W)\",\"values\":{\"location\":\"40.750703,-73." +"989787\"}}}\n" +"{\"dataset\":\"Starbucks\",\"type\":\"add\",\"body\":{\"table\":\"Store\",\"key\":\"80th & York" +" - New York NY (W)\",\"values\":{\"location\":\"40.772204,-73.949862\"}}}\n" +"{\"dataset\":\"Starbucks\",\"type\":\"add\",\"body\":{\"table\":\"Store\",\"key\":\"Columbus @ " +"67th - New York NY (W)\",\"values\":{\"location\":\"40.774009,-73.981472\"}}}\n" +"{\"dataset\":\"Starbucks\",\"type\":\"add\",\"body\":{\"table\":\"Store\",\"key\":\"45th & Broa" +"dway - New York NY (W)\",\"values\":{\"location\":\"40.75766,-73.985719\"}}}\n" +"{\"dataset\":\"Starbucks\",\"type\":\"add\",\"body\":{\"table\":\"Store\",\"key\":\"Marriott Ma" +"rquis - Lobby - New York NY\",\"values\":{\"location\":\"40.759123,-73.984927\"}}}\n" +"{\"dataset\":\"Starbucks\",\"type\":\"add\",\"body\":{\"table\":\"Store\",\"key\":\"Second @ 81" +"st - New York NY (W)\",\"values\":{\"location\":\"40.77466,-73.954447\"}}}\n" +"{\"dataset\":\"Starbucks\",\"type\":\"add\",\"body\":{\"table\":\"Store\",\"key\":\"52nd & Seve" +"nth - New York NY (W)\",\"values\":{\"location\":\"40.761829,-73.981141\"}}}\n" +"{\"dataset\":\"Starbucks\",\"type\":\"add\",\"body\":{\"table\":\"Store\",\"key\":\"1585 Broadw" +"ay (47th) - New York NY (W)\",\"values\":{\"location\":\"40.759806,-73.985066\"}}}\n" +"{\"dataset\":\"Starbucks\",\"type\":\"add\",\"body\":{\"table\":\"Store\",\"key\":\"85th & Firs" +"t - New York NY (W)\",\"values\":{\"location\":\"40.776101,-73.949971\"}}}\n" +"{\"dataset\":\"Starbucks\",\"type\":\"add\",\"body\":{\"table\":\"Store\",\"key\":\"92nd & 3rd " +"- New York NY (W)\",\"values\":{\"location\":\"40.782606,-73.951235\"}}}\n" +"{\"dataset\":\"Starbucks\",\"type\":\"add\",\"body\":{\"table\":\"Store\",\"key\":\"165 Broadwa" +"y - 1 Liberty - New York NY (W)\",\"values\":{\"location\":\"40.709727,-74.011395\"}" +"}}\n" +"{\"dataset\":\"Starbucks\",\"type\":\"add\",\"body\":{\"table\":\"Store\",\"key\":\"1656 Broadw" +"ay - New York NY (W)\",\"values\":{\"location\":\"40.762434,-73.983364\"}}}\n" +"{\"dataset\":\"Starbucks\",\"type\":\"add\",\"body\":{\"table\":\"Store\",\"key\":\"54th & Broa" +"dway - New York NY (W)\",\"values\":{\"location\":\"40.764275,-73.982361\"}}}\n" +"{\"dataset\":\"Starbucks\",\"type\":\"add\",\"body\":{\"table\":\"Store\",\"key\":\"Limited Bra" +"nds-NYC - New York NY\",\"values\":{\"location\":\"40.765219,-73.982025\"}}}\n" +"{\"dataset\":\"Starbucks\",\"type\":\"add\",\"body\":{\"table\":\"Store\",\"key\":\"19th & 8th " +"- New York NY (W)\",\"values\":{\"location\":\"40.743218,-74.000605\"}}}\n" +"{\"dataset\":\"Starbucks\",\"type\":\"add\",\"body\":{\"table\":\"Store\",\"key\":\"60th & Broa" +"dway-II - New York NY (W)\",\"values\":{\"location\":\"40.769196,-73.982576\"}}}\n" +"{\"dataset\":\"Starbucks\",\"type\":\"add\",\"body\":{\"table\":\"Store\",\"key\":\"63rd & Broa" +"dway - New York NY (W)\",\"values\":{\"location\":\"40.771376,-73.982709\"}}}\n" +"{\"dataset\":\"Starbucks\",\"type\":\"add\",\"body\":{\"table\":\"Store\",\"key\":\"195 Broadwa" +"y - New York NY (W)\",\"values\":{\"location\":\"40.710703,-74.009485\"}}}\n" +"{\"dataset\":\"Starbucks\",\"type\":\"add\",\"body\":{\"table\":\"Store\",\"key\":\"2 Broadway " +"- New York NY (W)\",\"values\":{\"location\":\"40.704538,-74.01324\"}}}\n" +"{\"dataset\":\"Starbucks\",\"type\":\"add\",\"body\":{\"table\":\"Store\",\"key\":\"2 Columbus " +"Ave. - New York NY (W)\",\"values\":{\"location\":\"40.769262,-73.984764\"}}}\n" +"{\"dataset\":\"Starbucks\",\"type\":\"add\",\"body\":{\"table\":\"Store\",\"key\":\"NY Plaza - " +"New York NY (W)\",\"values\":{\"location\":\"40.702802,-74.012784\"}}}\n" +"{\"dataset\":\"Starbucks\",\"type\":\"add\",\"body\":{\"table\":\"Store\",\"key\":\"36th and Ma" +"dison - New York NY (W)\",\"values\":{\"location\":\"40.748917,-73.982683\"}}}\n" +"{\"dataset\":\"Starbucks\",\"type\":\"add\",\"body\":{\"table\":\"Store\",\"key\":\"125th St. b" +"twn Adam Clayton & FDB - New York NY\",\"values\":{\"location\":\"40.808952,-73.9482" +"29\"}}}\n" +"{\"dataset\":\"Starbucks\",\"type\":\"add\",\"body\":{\"table\":\"Store\",\"key\":\"70th & Broa" +"dway - New York NY (W)\",\"values\":{\"location\":\"40.777463,-73.982237\"}}}\n" +"~~~" +msgstr "" + +msgid "Open another terminal and send those two jsons to the fluentd server." +msgstr "" + +msgid "Send `ddl.jsons` as follows:" +msgstr "" + +msgid "" +"~~~\n" +"# droonga-request --tag starbucks ddl.jsons\n" +"Elapsed time: 0.060984\n" +"[\n" +" \"droonga.message\",\n" +" 1392611486,\n" +" {\n" +" \"inReplyTo\": \"1392611486.207507\",\n" +" \"statusCode\": 200,\n" +" \"type\": \"table_create.result\",\n" +" \"body\": [\n" +" [\n" +" 0,\n" +" 1392611486.2097359,\n" +" 0.026822328567504883\n" +" ],\n" +" true\n" +" ]\n" +" }\n" +"]\n" +"Elapsed time: 0.007164\n" +"[\n" +" \"droonga.message\",\n" +" 1392611486,\n" +" {\n" +" \"inReplyTo\": \"1392611486.268766\",\n" +" \"statusCode\": 200,\n" +" \"type\": \"column_create.result\",\n" +" \"body\": [\n" +" [\n" +" 0,\n" +" 1392611486.269676,\n" +" 0.0010280609130859375\n" +" ],\n" +" true\n" +" ]\n" +" }\n" +"]\n" +"Elapsed time: 0.008584\n" +"[\n" +" \"droonga.message\",\n" +" 1392611486,\n" +" {\n" +" \"inReplyTo\": \"1392611486.2760692\",\n" +" \"statusCode\": 200,\n" +" \"type\": \"table_create.result\",\n" +" \"body\": [\n" +" [\n" +" 0,\n" +" 1392611486.276955,\n" +" 0.002329111099243164\n" +" ],\n" +" true\n" +" ]\n" +" }\n" +"]\n" +"Elapsed time: 0.109383\n" +"[\n" +" \"droonga.message\",\n" +" 1392611486,\n" +" {\n" +" \"inReplyTo\": \"1392611486.284704\",\n" +" \"statusCode\": 200,\n" +" \"type\": \"column_create.result\",\n" +" \"body\": [\n" +" [\n" +" 0,\n" +" 1392611486.2854872,\n" +" 0.00432896614074707\n" +" ],\n" +" true\n" +" ]\n" +" }\n" +"]\n" +"Elapsed time: 0.008829\n" +"[\n" +" \"droonga.message\",\n" +" 1392611486,\n" +" {\n" +" \"inReplyTo\": \"1392611486.394273\",\n" +" \"statusCode\": 200,\n" +" \"type\": \"table_create.result\",\n" +" \"body\": [\n" +" [\n" +" 0,\n" +" 1392611486.395301,\n" +" 0.0017240047454833984\n" +" ],\n" +" true\n" +" ]\n" +" }\n" +"]\n" +"Elapsed time: 0.11633\n" +"[\n" +" \"droonga.message\",\n" +" 1392611486,\n" +" {\n" +" \"inReplyTo\": \"1392611486.4032152\",\n" +" \"statusCode\": 200,\n" +" \"type\": \"column_create.result\",\n" +" \"body\": [\n" +" [\n" +" 0,\n" +" 1392611486.404574,\n" +" 0.018894195556640625\n" +" ],\n" +" true\n" +" ]\n" +" }\n" +"]\n" +"~~~" +msgstr "" + +msgid "~~~" +msgstr "" + +msgid "" +"$ droonga-request --tag starbucks stores.jsons\n" +"Elapsed time: 0.251712\n" +"[\n" +" \"droonga.message\",\n" +" 1392611703,\n" +" {\n" +" \"inReplyTo\": \"1392611703.414268\",\n" +" \"statusCode\": 200,\n" +" \"type\": \"add.result\",\n" +" \"body\": true\n" +" }\n" +"]\n" +"Elapsed time: 0.007161\n" +"[\n" +" \"droonga.message\",\n" +" 1392611703,\n" +" {\n" +" \"inReplyTo\": \"1392611703.666198\",\n" +" \"statusCode\": 200,\n" +" \"type\": \"add.result\",\n" +" \"body\": true\n" +" }\n" +"]\n" +"Elapsed time: 0.006794\n" +"[\n" +" \"droonga.message\",\n" +" 1392611703,\n" +" {\n" +" \"inReplyTo\": \"1392611703.6735082\",\n" +" \"statusCode\": 200,\n" +" \"type\": \"add.result\",\n" +" \"body\": true\n" +" }\n" +"]\n" +"Elapsed time: 0.070859\n" +"[\n" +" \"droonga.message\",\n" +" 1392611703,\n" +" {\n" +" \"inReplyTo\": \"1392611703.680408\",\n" +" \"statusCode\": 200,\n" +" \"type\": \"add.result\",\n" +" \"body\": true\n" +" }\n" +"]\n" +"Elapsed time: 0.064862\n" +"[\n" +" \"droonga.message\",\n" +" 1392611703,\n" +" {\n" +" \"inReplyTo\": \"1392611703.7514088\",\n" +" \"statusCode\": 200,\n" +" \"type\": \"add.result\",\n" +" \"body\": true\n" +" }\n" +"]\n" +"Elapsed time: 0.009247\n" +"[\n" +" \"droonga.message\",\n" +" 1392611703,\n" +" {\n" +" \"inReplyTo\": \"1392611703.816423\",\n" +" \"statusCode\": 200,\n" +" \"type\": \"add.result\",\n" +" \"body\": true\n" +" }\n" +"]\n" +"Elapsed time: 0.012615\n" +"[\n" +" \"droonga.message\",\n" +" 1392611703,\n" +" {\n" +" \"inReplyTo\": \"1392611703.825906\",\n" +" \"statusCode\": 200,\n" +" \"type\": \"add.result\",\n" +" \"body\": true\n" +" }\n" +"]\n" +"Elapsed time: 0.01329\n" +"[\n" +" \"droonga.message\",\n" +" 1392611703,\n" +" {\n" +" \"inReplyTo\": \"1392611703.838811\",\n" +" \"statusCode\": 200,\n" +" \"type\": \"add.result\",\n" +" \"body\": true\n" +" }\n" +"]\n" +"Elapsed time: 0.016937\n" +"[\n" +" \"droonga.message\",\n" +" 1392611703,\n" +" {\n" +" \"inReplyTo\": \"1392611703.852271\",\n" +" \"statusCode\": 200,\n" +" \"type\": \"add.result\",\n" +" \"body\": true\n" +" }\n" +"]\n" +"Elapsed time: 0.009726\n" +"[\n" +" \"droonga.message\",\n" +" 1392611703,\n" +" {\n" +" \"inReplyTo\": \"1392611703.8693151\",\n" +" \"statusCode\": 200,\n" +" \"type\": \"add.result\",\n" +" \"body\": true\n" +" }\n" +"]\n" +"Elapsed time: 0.009445\n" +"[\n" +" \"droonga.message\",\n" +" 1392611703,\n" +" {\n" +" \"inReplyTo\": \"1392611703.879232\",\n" +" \"statusCode\": 200,\n" +" \"type\": \"add.result\",\n" +" \"body\": true\n" +" }\n" +"]\n" +"Elapsed time: 0.003686\n" +"[\n" +" \"droonga.message\",\n" +" 1392611703,\n" +" {\n" +" \"inReplyTo\": \"1392611703.888693\",\n" +" \"statusCode\": 200,\n" +" \"type\": \"add.result\",\n" +" \"body\": true\n" +" }\n" +"]\n" +"Elapsed time: 0.00309\n" +"[\n" +" \"droonga.message\",\n" +" 1392611703,\n" +" {\n" +" \"inReplyTo\": \"1392611703.892619\",\n" +" \"statusCode\": 200,\n" +" \"type\": \"add.result\",\n" +" \"body\": true\n" +" }\n" +"]\n" +"Elapsed time: 0.007988\n" +"[\n" +" \"droonga.message\",\n" +" 1392611703,\n" +" {\n" +" \"inReplyTo\": \"1392611703.895704\",\n" +" \"statusCode\": 200,\n" +" \"type\": \"add.result\",\n" +" \"body\": true\n" +" }\n" +"]\n" +"Elapsed time: 0.003158\n" +"[\n" +" \"droonga.message\",\n" +" 1392611703,\n" +" {\n" +" \"inReplyTo\": \"1392611703.903796\",\n" +" \"statusCode\": 200,\n" +" \"type\": \"add.result\",\n" +" \"body\": true\n" +" }\n" +"]\n" +"Elapsed time: 0.006433\n" +"[\n" +" \"droonga.message\",\n" +" 1392611703,\n" +" {\n" +" \"inReplyTo\": \"1392611703.907073\",\n" +" \"statusCode\": 200,\n" +" \"type\": \"add.result\",\n" +" \"body\": true\n" +" }\n" +"]\n" +"Elapsed time: 0.006858\n" +"[\n" +" \"droonga.message\",\n" +" 1392611703,\n" +" {\n" +" \"inReplyTo\": \"1392611703.913633\",\n" +" \"statusCode\": 200,\n" +" \"type\": \"add.result\",\n" +" \"body\": true\n" +" }\n" +"]\n" +"Elapsed time: 0.003178\n" +"[\n" +" \"droonga.message\",\n" +" 1392611703,\n" +" {\n" +" \"inReplyTo\": \"1392611703.920607\",\n" +" \"statusCode\": 200,\n" +" \"type\": \"add.result\",\n" +" \"body\": true\n" +" }\n" +"]\n" +"Elapsed time: 0.002921\n" +"[\n" +" \"droonga.message\",\n" +" 1392611703,\n" +" {\n" +" \"inReplyTo\": \"1392611703.923857\",\n" +" \"statusCode\": 200,\n" +" \"type\": \"add.result\",\n" +" \"body\": true\n" +" }\n" +"]\n" +"Elapsed time: 0.002627\n" +"[\n" +" \"droonga.message\",\n" +" 1392611703,\n" +" {\n" +" \"inReplyTo\": \"1392611703.926882\",\n" +" \"statusCode\": 200,\n" +" \"type\": \"add.result\",\n" +" \"body\": true\n" +" }\n" +"]\n" +"Elapsed time: 0.002955\n" +"[\n" +" \"droonga.message\",\n" +" 1392611703,\n" +" {\n" +" \"inReplyTo\": \"1392611703.92959\",\n" +" \"statusCode\": 200,\n" +" \"type\": \"add.result\",\n" +" \"body\": true\n" +" }\n" +"]\n" +"Elapsed time: 0.003133\n" +"[\n" +" \"droonga.message\",\n" +" 1392611703,\n" +" {\n" +" \"inReplyTo\": \"1392611703.932686\",\n" +" \"statusCode\": 200,\n" +" \"type\": \"add.result\",\n" +" \"body\": true\n" +" }\n" +"]\n" +"Elapsed time: 0.002871\n" +"[\n" +" \"droonga.message\",\n" +" 1392611703,\n" +" {\n" +" \"inReplyTo\": \"1392611703.9359381\",\n" +" \"statusCode\": 200,\n" +" \"type\": \"add.result\",\n" +" \"body\": true\n" +" }\n" +"]\n" +"Elapsed time: 0.00274\n" +"[\n" +" \"droonga.message\",\n" +" 1392611703,\n" +" {\n" +" \"inReplyTo\": \"1392611703.938964\",\n" +" \"statusCode\": 200,\n" +" \"type\": \"add.result\",\n" +" \"body\": true\n" +" }\n" +"]\n" +"Elapsed time: 0.002905\n" +"[\n" +" \"droonga.message\",\n" +" 1392611703,\n" +" {\n" +" \"inReplyTo\": \"1392611703.941767\",\n" +" \"statusCode\": 200,\n" +" \"type\": \"add.result\",\n" +" \"body\": true\n" +" }\n" +"]\n" +"Elapsed time: 0.002512\n" +"[\n" +" \"droonga.message\",\n" +" 1392611703,\n" +" {\n" +" \"inReplyTo\": \"1392611703.94483\",\n" +" \"statusCode\": 200,\n" +" \"type\": \"add.result\",\n" +" \"body\": true\n" +" }\n" +"]\n" +"Elapsed time: 0.002553\n" +"[\n" +" \"droonga.message\",\n" +" 1392611703,\n" +" {\n" +" \"inReplyTo\": \"1392611703.947414\",\n" +" \"statusCode\": 200,\n" +" \"type\": \"add.result\",\n" +" \"body\": true\n" +" }\n" +"]\n" +"Elapsed time: 0.002482\n" +"[\n" +" \"droonga.message\",\n" +" 1392611703,\n" +" {\n" +" \"inReplyTo\": \"1392611703.950102\",\n" +" \"statusCode\": 200,\n" +" \"type\": \"add.result\",\n" +" \"body\": true\n" +" }\n" +"]\n" +"Elapsed time: 0.00294\n" +"[\n" +" \"droonga.message\",\n" +" 1392611703,\n" +" {\n" +" \"inReplyTo\": \"1392611703.952671\",\n" +" \"statusCode\": 200,\n" +" \"type\": \"add.result\",\n" +" \"body\": true\n" +" }\n" +"]\n" +"Elapsed time: 0.003141\n" +"[\n" +" \"droonga.message\",\n" +" 1392611703,\n" +" {\n" +" \"inReplyTo\": \"1392611703.955711\",\n" +" \"statusCode\": 200,\n" +" \"type\": \"add.result\",\n" +" \"body\": true\n" +" }\n" +"]\n" +"Elapsed time: 0.002479\n" +"[\n" +" \"droonga.message\",\n" +" 1392611703,\n" +" {\n" +" \"inReplyTo\": \"1392611703.958953\",\n" +" \"statusCode\": 200,\n" +" \"type\": \"add.result\",\n" +" \"body\": true\n" +" }\n" +"]\n" +"Elapsed time: 0.002375\n" +"[\n" +" \"droonga.message\",\n" +" 1392611703,\n" +" {\n" +" \"inReplyTo\": \"1392611703.9615061\",\n" +" \"statusCode\": 200,\n" +" \"type\": \"add.result\",\n" +" \"body\": true\n" +" }\n" +"]\n" +"Elapsed time: 0.002571\n" +"[\n" +" \"droonga.message\",\n" +" 1392611703,\n" +" {\n" +" \"inReplyTo\": \"1392611703.963968\",\n" +" \"statusCode\": 200,\n" +" \"type\": \"add.result\",\n" +" \"body\": true\n" +" }\n" +"]\n" +"Elapsed time: 0.003212\n" +"[\n" +" \"droonga.message\",\n" +" 1392611703,\n" +" {\n" +" \"inReplyTo\": \"1392611703.966677\",\n" +" \"statusCode\": 200,\n" +" \"type\": \"add.result\",\n" +" \"body\": true\n" +" }\n" +"]\n" +"Elapsed time: 0.002769\n" +"[\n" +" \"droonga.message\",\n" +" 1392611703,\n" +" {\n" +" \"inReplyTo\": \"1392611703.970025\",\n" +" \"statusCode\": 200,\n" +" \"type\": \"add.result\",\n" +" \"body\": true\n" +" }\n" +"]\n" +"~~~" +msgstr "" + +msgid "Now a Droonga engine for searching Starbucks stores database is ready." +msgstr "" + +msgid "### Send request with droonga-request" +msgstr "" + +msgid "Check if it is working. Create a query as a JSON file as follows." +msgstr "" + +msgid "search-all-stores.json:" +msgstr "" + +msgid "" +"~~~\n" +"{\n" +" \"dataset\": \"Starbucks\"\n" +" \"queries\": {\n" +" \"stores\": {\n" +" \"source\": \"Store\",\n" +" \"output\": {\n" +" \"elements\": [\n" +" \"startTime\",\n" +" \"elapsedTime\",\n" +" \"count\",\n" +" \"attributes\",\n" +" \"records\"\n" +" ],\n" +" \"attributes\": [\"_key\"],\n" +" \"limit\": -1\n" +" }\n" +" }\n" +" }\n" +"}\n" +"~~~" +msgstr "" + +msgid "Send the request to Droonga Engine:" +msgstr "Droonga Engine にリクエストを送信します:" + +msgid "" +"~~~\n" +"# droonga-request --tag starbucks search-all-stores.json\n" +"Elapsed time: 0.202101\n" +"[\n" +" \"droonga.message\",\n" +" 1392614906,\n" +" {\n" +" \"inReplyTo\": \"1392614905.993328\",\n" +" \"statusCode\": 200,\n" +" \"type\": \"search.result\",\n" +" \"body\": {\n" +" \"stores\": {\n" +" \"count\": 35,\n" +" \"records\": [\n" +" [\n" +" \"1st Avenue & 75th St. - New York NY (W)\"\n" +" ],\n" +" [\n" +" \"76th & Second - New York NY (W)\"\n" +" ],\n" +" [\n" +" \"2nd Ave. & 9th Street - New York NY\"\n" +" ],\n" +" [\n" +" \"84th & Third Ave - New York NY (W)\"\n" +" ],\n" +" [\n" +" \"Macy's 35th Street Balcony - New York NY\"\n" +" ],\n" +" [\n" +" \"80th & York - New York NY (W)\"\n" +" ],\n" +" [\n" +" \"45th & Broadway - New York NY (W)\"\n" +" ],\n" +" [\n" +" \"1585 Broadway (47th) - New York NY (W)\"\n" +" ],\n" +" [\n" +" \"85th & First - New York NY (W)\"\n" +" ],\n" +" [\n" +" \"1656 Broadway - New York NY (W)\"\n" +" ],\n" +" [\n" +" \"2 Broadway - New York NY (W)\"\n" +" ],\n" +" [\n" +" \"NY Plaza - New York NY (W)\"\n" +" ],\n" +" [\n" +" \"70th & Broadway - New York NY (W)\"\n" +" ],\n" +" [\n" +" \"15th & Third - New York NY (W)\"\n" +" ],\n" +" [\n" +" \"West 43rd and Broadway - New York NY (W)\"\n" +" ],\n" +" [\n" +" \"Macy's 6th Floor - Herald Square - New York NY (W)\"\n" +" ],\n" +" [\n" +" \"Herald Square- Macy's - New York NY\"\n" +" ],\n" +" [\n" +" \"Macy's 5th Floor - Herald Square - New York NY (W)\"\n" +" ],\n" +" [\n" +" \"52nd & Seventh - New York NY (W)\"\n" +" ],\n" +" [\n" +" \"92nd & 3rd - New York NY (W)\"\n" +" ],\n" +" [\n" +" \"Limited Brands-NYC - New York NY\"\n" +" ],\n" +" [\n" +" \"19th & 8th - New York NY (W)\"\n" +" ],\n" +" [\n" +" \"60th & Broadway-II - New York NY (W)\"\n" +" ],\n" +" [\n" +" \"36th and Madison - New York NY (W)\"\n" +" ],\n" +" [\n" +" \"125th St. btwn Adam Clayton & FDB - New York NY\"\n" +" ],\n" +" [\n" +" \"41st and Broadway - New York NY (W)\"\n" +" ],\n" +" [\n" +" \"150 E. 42nd Street - New York NY (W)\"\n" +" ],\n" +" [\n" +" \"Columbus @ 67th - New York NY (W)\"\n" +" ],\n" +" [\n" +" \"Marriott Marquis - Lobby - New York NY\"\n" +" ],\n" +" [\n" +" \"Second @ 81st - New York NY (W)\"\n" +" ],\n" +" [\n" +" \"165 Broadway - 1 Liberty - New York NY (W)\"\n" +" ],\n" +" [\n" +" \"54th & Broadway - New York NY (W)\"\n" +" ],\n" +" [\n" +" \"63rd & Broadway - New York NY (W)\"\n" +" ],\n" +" [\n" +" \"195 Broadway - New York NY (W)\"\n" +" ],\n" +" [\n" +" \"2 Columbus Ave. - New York NY (W)\"\n" +" ]\n" +" ]\n" +" }\n" +" }\n" +" }\n" +"]\n" +"~~~" +msgstr "" + +msgid "" +"Now the store names are retrieved. The engine looks working correctly.\n" "Next, setup a protocol adapter for clients to accept search requests using pop" "ular protocols." msgstr "" -"これで、スターバックスの店舗のデータベースを検索するための Droonga Engine ができました。\n" -"引き続き Protocol Adapter を構築して、検索リクエストを受け付けられるようにしましょう。" +"店舗の名前が取得できました。エンジンは正しく動作しているようです。引き続き Protocol Adapter を構築して、検索リクエストを受け付けられるよう" +"にしましょう。" msgid "## Build a protocol adapter" msgstr "## Protocol Adapter を構築する" Modified: _po/ja/tutorial/plugin-development/adapter/index.po (+247 -122) =================================================================== --- _po/ja/tutorial/plugin-development/adapter/index.po 2014-02-17 16:32:06 +0900 (01c0422) +++ _po/ja/tutorial/plugin-development/adapter/index.po 2014-02-17 16:36:15 +0900 (001d83f) @@ -189,24 +189,7 @@ msgstr "" msgid "### Test" msgstr "" -msgid "" -"In the [basic tutorial][], we have communicated with the Droonga Engine based " -"on `fluent-plugin-droonga`, via the Protocol Adapter built with `expres-droong" -"a`. For plugin development, sending requests directly to the Droonga Engine ca" -"n be more handy way to debug.\n" -"We use `fluent-cat` command for this purpose." -msgstr "" - -msgid "Doing in this way also help us to understand internal structure of Droonga." -msgstr "" - -msgid "" -"In the [basic tutorial][], we have used `fluent-cat` to setup database schema " -"and import data. Do you remember? Sending search request can be done in the si" -"milar way." -msgstr "" - -msgid "First, create a request as a JSON." +msgid "Check if the engine is working. First, create a request as a JSON." msgstr "" msgid "search-columbus.json:" @@ -215,10 +198,8 @@ msgstr "" msgid "" "~~~json\n" "{\n" -" \"id\" : \"search:0\",\n" " \"dataset\" : \"Starbucks\",\n" " \"type\" : \"search\",\n" -" \"replyTo\" : \"localhost:24224/output\",\n" " \"body\" : {\n" " \"queries\" : {\n" " \"stores\" : {\n" @@ -251,41 +232,41 @@ msgid "" "y\"` element." msgstr "" -msgid "" -"`fluent-cat` expects one line per one JSON object. So we need to use `tr` comm" -"and to remove line breaks before passing the JSON to `fluent-cat`:" -msgstr "" - -msgid "" -"~~~\n" -"# cat search-columbus.json | tr -d \"\n" -"\" | fluent-cat starbucks.message\n" -"~~~" -msgstr "" - -msgid "This will output something like below to fluentd's log in `fluentd.log`:" +msgid "Send the request to engine with `droonga-request`:" msgstr "" msgid "" "~~~\n" -"2014-02-03 14:22:54 +0900 output.message: {\"inReplyTo\":\"search:0\",\"statusCode\"" -":200,\"type\":\"search.result\",\"body\":{\"stores\":{\"count\":2,\"records\":[[\"2 Columbu" -"s Ave. - New York NY (W)\"],[\"Columbus @ 67th - New York NY (W)\"]]}}}\n" +"# droonga-request --tag starbucks search-columbus.json\n" +"Elapsed time: 0.021544\n" +"[\n" +" \"droonga.message\",\n" +" 1392617533,\n" +" {\n" +" \"inReplyTo\": \"1392617533.9644868\",\n" +" \"statusCode\": 200,\n" +" \"type\": \"search.result\",\n" +" \"body\": {\n" +" \"stores\": {\n" +" \"count\": 2,\n" +" \"records\": [\n" +" [\n" +" \"Columbus @ 67th - New York NY (W)\"\n" +" ],\n" +" [\n" +" \"2 Columbus Ave. - New York NY (W)\"\n" +" ]\n" +" ]\n" +" }\n" +" }\n" +" }\n" +"]\n" "~~~" msgstr "" msgid "This is the search result." msgstr "" -msgid "If you have [jq][] installed, you can use `jq` instead of `tr`:" -msgstr "" - -msgid "" -"~~~\n" -"# jq -c . search-columbus.json | fluent-cat starbucks.message\n" -"~~~" -msgstr "" - msgid "### Do something in the plugin: take logs" msgstr "" @@ -322,7 +303,36 @@ msgstr "" msgid "Restart fluentd:" msgstr "" -msgid "Send the request same as the previous:" +msgid "Send the request same as the previous section:" +msgstr "" + +msgid "" +"~~~\n" +"# droonga-request --tag starbucks search-columbus.json\n" +"Elapsed time: 0.014714\n" +"[\n" +" \"droonga.message\",\n" +" 1392618037,\n" +" {\n" +" \"inReplyTo\": \"1392618037.935901\",\n" +" \"statusCode\": 200,\n" +" \"type\": \"search.result\",\n" +" \"body\": {\n" +" \"stores\": {\n" +" \"count\": 2,\n" +" \"records\": [\n" +" [\n" +" \"Columbus @ 67th - New York NY (W)\"\n" +" ],\n" +" [\n" +" \"2 Columbus Ave. - New York NY (W)\"\n" +" ]\n" +" ]\n" +" }\n" +" }\n" +" }\n" +"]\n" +"~~~" msgstr "" msgid "You will see something like below fluentd's log in `fluentd.log`:" @@ -330,16 +340,14 @@ msgstr "" msgid "" "~~~\n" -"2014-02-03 16:56:27 +0900 [info]: SampleLoggerPlugin::Adapter message=#<Droong" -"a::InputMessage:0x007ff36a38cb28 @raw_message={\"body\"=>{\"queries\"=>{\"stores\"=>" -"{\"output\"=>{\"limit\"=>-1, \"attributes\"=>[\"_key\"], \"elements\"=>[\"startTime\", \"el" -"apsedTime\", \"count\", \"attributes\", \"records\"]}, \"condition\"=>{\"matchTo\"=>\"_key" -"\", \"query\"=>\"Columbus\"}, \"source\"=>\"Store\"}}}, \"replyTo\"=>{\"type\"=>\"search.res" -"ult\", \"to\"=>\"localhost:24224/output\"}, \"type\"=>\"search\", \"dataset\"=>\"Starbucks" -"\", \"id\"=>\"search\"}>\n" -"2014-02-03 16:56:27 +0900 output.message: {\"inReplyTo\":\"search\",\"statusCode\":2" -"00,\"type\":\"search.result\",\"body\":{\"stores\":{\"count\":2,\"records\":[[\"2 Columbus " -"Ave. - New York NY (W)\"],[\"Columbus @ 67th - New York NY (W)\"]]}}}\n" +"2014-02-17 15:20:37 +0900 [info]: SampleLoggerPlugin::Adapter message=#<Droong" +"a::InputMessage:0x007f8ae3e1dd98 @raw_message={\"dataset\"=>\"Starbucks\", \"type\"=" +">\"search\", \"body\"=>{\"queries\"=>{\"stores\"=>{\"source\"=>\"Store\", \"condition\"=>{\"q" +"uery\"=>\"Columbus\", \"matchTo\"=>\"_key\"}, \"output\"=>{\"elements\"=>[\"startTime\", \"e" +"lapsedTime\", \"count\", \"attributes\", \"records\"], \"attributes\"=>[\"_key\"], \"limit" +"\"=>-1}}}}, \"replyTo\"=>{\"type\"=>\"search.result\", \"to\"=>\"127.0.0.1:64591/droonga" +"\"}, \"id\"=>\"1392618037.935901\", \"date\"=>\"2014-02-17 15:20:37 +0900\", \"appliedAd" +"apters\"=>[]}>\n" "~~~" msgstr "" @@ -374,18 +382,32 @@ msgid "" "on." msgstr "" +msgid "Send the request same as the previous:" +msgstr "" + msgid "" "~~~\n" -"2014-02-03 18:47:54 +0900 [info]: SampleLoggerPlugin::Adapter message=#<Droong" -"a::InputMessage:0x007f913ca6e918 @raw_message={\"body\"=>{\"queries\"=>{\"stores\"=>" -"{\"output\"=>{\"limit\"=>-1, \"attributes\"=>[\"_key\"], \"elements\"=>[\"startTime\", \"el" -"apsedTime\", \"count\", \"attributes\", \"records\"]}, \"condition\"=>{\"matchTo\"=>\"_key" -"\", \"query\"=>\"Columbus\"}, \"source\"=>\"Store\"}}}, \"replyTo\"=>{\"type\"=>\"search.res" -"ult\", \"to\"=>\"localhost:24224/output\"}, \"type\"=>\"search\", \"dataset\"=>\"Starbucks" -"\", \"id\"=>\"search\"}>\n" -"2014-02-03 18:47:54 +0900 output.message: {\"inReplyTo\":\"search\",\"statusCode\":2" -"00,\"type\":\"search.result\",\"body\":{\"stores\":{\"count\":2,\"records\":[[\"2 Columbus " -"Ave. - New York NY (W)\"]]}}}\n" +"$ droonga-request --tag starbucks search-columbus.json\n" +"Elapsed time: 0.017343\n" +"[\n" +" \"droonga.message\",\n" +" 1392618279,\n" +" {\n" +" \"inReplyTo\": \"1392618279.0578449\",\n" +" \"statusCode\": 200,\n" +" \"type\": \"search.result\",\n" +" \"body\": {\n" +" \"stores\": {\n" +" \"count\": 2,\n" +" \"records\": [\n" +" [\n" +" \"Columbus @ 67th - New York NY (W)\"\n" +" ]\n" +" ]\n" +" }\n" +" }\n" +" }\n" +"]\n" "~~~" msgstr "" @@ -394,6 +416,19 @@ msgid "" " [search][] for details of the `search` command." msgstr "" +msgid "" +"~~~\n" +"2014-02-17 15:24:39 +0900 [info]: SampleLoggerPlugin::Adapter message=#<Droong" +"a::InputMessage:0x007f956685c908 @raw_message={\"dataset\"=>\"Starbucks\", \"type\"=" +">\"search\", \"body\"=>{\"queries\"=>{\"stores\"=>{\"source\"=>\"Store\", \"condition\"=>{\"q" +"uery\"=>\"Columbus\", \"matchTo\"=>\"_key\"}, \"output\"=>{\"elements\"=>[\"startTime\", \"e" +"lapsedTime\", \"count\", \"attributes\", \"records\"], \"attributes\"=>[\"_key\"], \"limit" +"\"=>-1}}}}, \"replyTo\"=>{\"type\"=>\"search.result\", \"to\"=>\"127.0.0.1:64616/droonga" +"\"}, \"id\"=>\"1392618279.0578449\", \"date\"=>\"2014-02-17 15:24:39 +0900\", \"appliedA" +"dapters\"=>[]}>\n" +"~~~" +msgstr "" + msgid "## Adaption for outgoing messages" msgstr "" @@ -408,15 +443,12 @@ msgstr "" msgid "" "Let's take logs of results of `search` command.\n" -"Define the `adapt_output` method to process outgoing messages, like below:" +"Define the `adapt_output` method to process outgoing messages.\n" +"Remove `adapt_input` at this moment for the simplicity." msgstr "" msgid "" " class Adapter < Droonga::Adapter\n" -" (snip)" -msgstr "" - -msgid "" " def adapt_output(output_message)\n" " $log.info(\"SampleLoggerPlugin::Adapter\", :message => output_message)" "\n" @@ -435,19 +467,47 @@ msgid "" "ion):" msgstr "" +msgid "" +"~~~\n" +"$ droonga-request --tag starbucks search-columbus.json\n" +"Elapsed time: 0.015491\n" +"[\n" +" \"droonga.message\",\n" +" 1392619269,\n" +" {\n" +" \"inReplyTo\": \"1392619269.184789\",\n" +" \"statusCode\": 200,\n" +" \"type\": \"search.result\",\n" +" \"body\": {\n" +" \"stores\": {\n" +" \"count\": 2,\n" +" \"records\": [\n" +" [\n" +" \"Columbus @ 67th - New York NY (W)\"\n" +" ],\n" +" [\n" +" \"2 Columbus Ave. - New York NY (W)\"\n" +" ]\n" +" ]\n" +" }\n" +" }\n" +" }\n" +"]\n" +"~~~" +msgstr "" + msgid "The fluentd's log should be like as follows:" msgstr "" msgid "" "~~~\n" -"2014-02-05 17:37:37 +0900 [info]: SampleLoggerPlugin::Adapter message=#<Droong" -"a::OutputMessage:0x007f8da265b698 @raw_message={\"body\"=>{\"stores\"=>{\"count\"=>2" -", \"records\"=>[[\"2 Columbus Ave. - New York NY (W)\"], [\"Columbus @ 67th - New " -"York NY (W)\"]]}}, \"replyTo\"=>{\"type\"=>\"search.result\", \"to\"=>\"localhost:24224" -"/output\"}, \"type\"=>\"search\", \"dataset\"=>\"Starbucks\", \"id\"=>\"search\"}>\n" -"2014-02-05 17:37:37 +0900 output.message: {\"inReplyTo\":\"search\",\"statusCode\":2" -"00,\"type\":\"search.result\",\"body\":{\"stores\":{\"count\":2,\"records\":[[\"2 Columbus " -"Ave. - New York NY (W)\"],[\"Columbus @ 67th - New York NY (W)\"]]}}}\n" +"2014-02-17 15:41:09 +0900 [info]: SampleLoggerPlugin::Adapter message=#<Droong" +"a::OutputMessage:0x007fddcad4d5a0 @raw_message={\"dataset\"=>\"Starbucks\", \"type\"" +"=>\"dispatcher\", \"body\"=>{\"stores\"=>{\"count\"=>2, \"records\"=>[[\"Columbus @ 67th " +"- New York NY (W)\"], [\"2 Columbus Ave. - New York NY (W)\"]]}}, \"replyTo\"=>{\"" +"type\"=>\"search.result\", \"to\"=>\"127.0.0.1:64724/droonga\"}, \"id\"=>\"1392619269.18" +"4789\", \"date\"=>\"2014-02-17 15:41:09 +0900\", \"appliedAdapters\"=>[\"Droonga::Plug" +"ins::SampleLoggerPlugin::Adapter\", \"Droonga::Plugins::Error::Adapter\"]}>\n" "~~~" msgstr "" @@ -481,26 +541,52 @@ msgstr "" msgid "Send the same search request:" msgstr "" -msgid "The results in `fluentd.log` will be like this:" -msgstr "" - msgid "" "~~~\n" -"2014-02-05 17:41:02 +0900 [info]: SampleLoggerPlugin::Adapter message=#<Droong" -"a::OutputMessage:0x007fb3c5291fc8 @raw_message={\"body\"=>{\"stores\"=>{\"count\"=>2" -", \"records\"=>[[\"2 Columbus Ave. - New York NY (W)\"], [\"Columbus @ 67th - New " -"York NY (W)\"]]}}, \"replyTo\"=>{\"type\"=>\"search.result\", \"to\"=>\"localhost:24224" -"/output\"}, \"type\"=>\"search\", \"dataset\"=>\"Starbucks\", \"id\"=>\"search\"}>\n" -"2014-02-05 17:41:02 +0900 output.message: {\"inReplyTo\":\"search\",\"statusCode\":2" -"00,\"type\":\"search.result\",\"body\":{\"stores\":{\"count\":2,\"records\":[[\"2 Columbus " -"Ave. - New York NY (W)\"],[\"Columbus @ 67th - New York NY (W)\"]],\"completedAt" -"\":\"2014-02-05T08:41:02.824361Z\"}}}\n" +"# droonga-request --tag starbucks search-columbus.json\n" +"Elapsed time: 0.013983\n" +"[\n" +" \"droonga.message\",\n" +" 1392619528,\n" +" {\n" +" \"inReplyTo\": \"1392619528.235121\",\n" +" \"statusCode\": 200,\n" +" \"type\": \"search.result\",\n" +" \"body\": {\n" +" \"stores\": {\n" +" \"count\": 2,\n" +" \"records\": [\n" +" [\n" +" \"Columbus @ 67th - New York NY (W)\"\n" +" ],\n" +" [\n" +" \"2 Columbus Ave. - New York NY (W)\"\n" +" ]\n" +" ],\n" +" \"completedAt\": \"2014-02-17T06:45:28.247669Z\"\n" +" }\n" +" }\n" +" }\n" +"]\n" "~~~" msgstr "" msgid "" "Now you can see `completedAt` attribute containing the time completed the requ" -"est." +"est.\n" +"The results in `fluentd.log` will be like this:" +msgstr "" + +msgid "" +"~~~\n" +"2014-02-17 15:45:28 +0900 [info]: SampleLoggerPlugin::Adapter message=#<Droong" +"a::OutputMessage:0x007fd384f3ab60 @raw_message={\"dataset\"=>\"Starbucks\", \"type\"" +"=>\"dispatcher\", \"body\"=>{\"stores\"=>{\"count\"=>2, \"records\"=>[[\"Columbus @ 67th " +"- New York NY (W)\"], [\"2 Columbus Ave. - New York NY (W)\"]]}}, \"replyTo\"=>{\"" +"type\"=>\"search.result\", \"to\"=>\"127.0.0.1:64849/droonga\"}, \"id\"=>\"1392619528.23" +"5121\", \"date\"=>\"2014-02-17 15:45:28 +0900\", \"appliedAdapters\"=>[\"Droonga::Plug" +"ins::SampleLoggerPlugin::Adapter\", \"Droonga::Plugins::Error::Adapter\"]}>\n" +"~~~" msgstr "" msgid "## Translation for both incoming and outgoing messages" @@ -621,10 +707,8 @@ msgstr "" msgid "" "~~~json\n" "{\n" -" \"id\" : \"storeSearch:0\",\n" " \"dataset\" : \"Starbucks\",\n" " \"type\" : \"storeSearch\",\n" -" \"replyTo\" : \"localhost:24224/output\",\n" " \"body\" : {\n" " \"query\" : \"Columbus\"\n" " }\n" @@ -637,8 +721,30 @@ msgstr "" msgid "" "~~~\n" -"# cat store-search-columbus.json | tr -d \"\n" -"\" | fluent-cat starbucks.message\n" +"# droonga-request --tag starbucks store-search-columbus.json\n" +"Elapsed time: 0.01494\n" +"[\n" +" \"droonga.message\",\n" +" 1392621168,\n" +" {\n" +" \"inReplyTo\": \"1392621168.0119512\",\n" +" \"statusCode\": 200,\n" +" \"type\": \"storeSearch.result\",\n" +" \"body\": {\n" +" \"stores\": {\n" +" \"count\": 2,\n" +" \"records\": [\n" +" [\n" +" \"Columbus @ 67th - New York NY (W)\"\n" +" ],\n" +" [\n" +" \"2 Columbus Ave. - New York NY (W)\"\n" +" ]\n" +" ]\n" +" }\n" +" }\n" +" }\n" +"]\n" "~~~" msgstr "" @@ -647,16 +753,12 @@ msgstr "" msgid "" "~~~\n" -"2014-02-06 15:20:07 +0900 [info]: StoreSearchPlugin::Adapter message=#<Droonga" -"::InputMessage:0x00000002a0de38 @raw_message={\"id\"=>\"storeSearch:0\", \"dataset\"" -"=>\"Starbucks\", \"type\"=>\"storeSearch\", \"replyTo\"=>{\"type\"=>\"storeSearch.result\"" -", \"to\"=>\"localhost:24224/output\"}, \"body\"=>{\"query\"=>\"Columbus\"}, \"appliedAdap" -"ters\"=>[]}>\n" -"2014-02-06 15:20:07 +0900 [info]: storeSearch query=\"Columbus\"\n" -"2014-02-06 15:20:07 +0900 output.message: {\"inReplyTo\":\"storeSearch:0\",\"status" -"Code\":200,\"type\":\"storeSearch.result\",\"body\":{\"stores\":{\"count\":2,\"records\":[[" -"\"2 Columbus Ave. - New York NY (W)\"],[\"Columbus @ 67th - New York NY (W)\"]]}" -"}}\n" +"2014-02-17 16:12:48 +0900 [info]: StoreSearchPlugin::Adapter message=#<Droonga" +"::InputMessage:0x007fe4791d3958 @raw_message={\"dataset\"=>\"Starbucks\", \"type\"=>" +"\"storeSearch\", \"body\"=>{\"query\"=>\"Columbus\"}, \"replyTo\"=>{\"type\"=>\"storeSearch" +".result\", \"to\"=>\"127.0.0.1:49934/droonga\"}, \"id\"=>\"1392621168.0119512\", \"date\"" +"=>\"2014-02-17 16:12:48 +0900\", \"appliedAdapters\"=>[]}>\n" +"2014-02-17 16:12:48 +0900 [info]: storeSearch query=\"Columbus\"\n" "~~~" msgstr "" @@ -691,6 +793,11 @@ msgid "" msgstr "" msgid "" +" class Adapter < Droonga::Adapter\n" +" (snip)" +msgstr "" + +msgid "" " def adapt_output(output_message)\n" " $log.info(\"StoreSearchPlugin::Adapter\", :message => output_message)" msgstr "" @@ -717,27 +824,45 @@ msgstr "" msgid "Send the request:" msgstr "" +msgid "" +"~~~\n" +"# droonga-request --tag starbucks store-search-columbus.json\n" +"Elapsed time: 0.014859\n" +"[\n" +" \"droonga.message\",\n" +" 1392621288,\n" +" {\n" +" \"inReplyTo\": \"1392621288.158763\",\n" +" \"statusCode\": 200,\n" +" \"type\": \"storeSearch.result\",\n" +" \"body\": [\n" +" \"Columbus @ 67th - New York NY (W)\",\n" +" \"2 Columbus Ave. - New York NY (W)\"\n" +" ]\n" +" }\n" +"]\n" +"~~~" +msgstr "" + msgid "The log in `fluentd.log` will be like this:" msgstr "" msgid "" "~~~\n" -"2014-02-06 16:04:45 +0900 [info]: StoreSearchPlugin::Adapter message=#<Droonga" -"::InputMessage:0x00000002a0de38 @raw_message={\"id\"=>\"storeSearch:0\", \"dataset\"" -"=>\"Starbucks\", \"type\"=>\"storeSearch\", \"replyTo\"=>{\"type\"=>\"storeSearch.result\"" -", \"to\"=>\"localhost:24224/output\"}, \"body\"=>{\"query\"=>\"Columbus\"}, \"appliedAdap" -"ters\"=>[]}>\n" -"2014-02-06 16:04:45 +0900 [info]: storeSearch query=\"Columbus\"\n" -"2014-02-06 16:04:45 +0900 [info]: StoreSearchPlugin::Adapter message=#<Droonga" -"::OutputMessage:0x00000002a34a88 @raw_message={\"id\"=>\"storeSearch:0\", \"dataset" -"\"=>\"Starbucks\", \"type\"=>\"search\", \"replyTo\"=>{\"type\"=>\"storeSearch.result\", \"t" -"o\"=>\"localhost:24224/output\"}, \"body\"=>{\"stores\"=>{\"count\"=>2, \"records\"=>[[\"2" -" Columbus Ave. - New York NY (W)\"], [\"Columbus @ 67th - New York NY (W)\"]]}}" -", \"appliedAdapters\"=>[\"Droonga::Plugins::StoreSearchPlugin::Adapter\", \"Droonga" -"::Plugins::Error::Adapter\"], \"originalTypes\"=>[\"storeSearch\"]}>\n" -"2014-02-06 16:04:45 +0900 output.message: {\"inReplyTo\":\"storeSearch:0\",\"status" -"Code\":200,\"type\":\"storeSearch.result\",\"body\":[\"2 Columbus Ave. - New York NY " -"(W)\",\"Columbus @ 67th - New York NY (W)\"]}\n" +"2014-02-17 16:14:48 +0900 [info]: StoreSearchPlugin::Adapter message=#<Droonga" +"::InputMessage:0x007ffb8ada9d68 @raw_message={\"dataset\"=>\"Starbucks\", \"type\"=>" +"\"storeSearch\", \"body\"=>{\"query\"=>\"Columbus\"}, \"replyTo\"=>{\"type\"=>\"storeSearch" +".result\", \"to\"=>\"127.0.0.1:49960/droonga\"}, \"id\"=>\"1392621288.158763\", \"date\"=" +">\"2014-02-17 16:14:48 +0900\", \"appliedAdapters\"=>[]}>\n" +"2014-02-17 16:14:48 +0900 [info]: storeSearch query=\"Columbus\"\n" +"2014-02-17 16:14:48 +0900 [info]: StoreSearchPlugin::Adapter message=#<Droonga" +"::OutputMessage:0x007ffb8ad78e48 @raw_message={\"dataset\"=>\"Starbucks\", \"type\"=" +">\"dispatcher\", \"body\"=>{\"stores\"=>{\"count\"=>2, \"records\"=>[[\"Columbus @ 67th -" +" New York NY (W)\"], [\"2 Columbus Ave. - New York NY (W)\"]]}}, \"replyTo\"=>{\"t" +"ype\"=>\"storeSearch.result\", \"to\"=>\"127.0.0.1:49960/droonga\"}, \"id\"=>\"139262128" +"8.158763\", \"date\"=>\"2014-02-17 16:14:48 +0900\", \"appliedAdapters\"=>[\"Droonga::" +"Plugins::StoreSearchPlugin::Adapter\", \"Droonga::Plugins::Error::Adapter\"], \"or" +"iginalTypes\"=>[\"storeSearch\"]}>\n" "~~~" msgstr "" Added: _po/ja/tutorial/plugin-development/handler/index.po (+513 -0) 100644 =================================================================== --- /dev/null +++ _po/ja/tutorial/plugin-development/handler/index.po 2014-02-17 16:36:15 +0900 (4d684b8) @@ -0,0 +1,513 @@ +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2011-11-20 22:17+0900\n" +"PO-Revision-Date: 2014-02-10 13:08+0900\n" +"Last-Translator: Droonga Project <droonga �� groonga.org>\n" +"Language-Team: Japanese\n" +"Language: ja\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=1; plural=0;\n" + +msgid "" +"---\n" +"title: \"Plugin: Handle requests\"\n" +"layout: en\n" +"---" +msgstr "" + +msgid "!!! WORK IN PROGRESS !!!" +msgstr "" + +msgid "" +"* TOC\n" +"{:toc}" +msgstr "" + +msgid "## The goal of this tutorial" +msgstr "## チュートリアルのゴール" + +msgid "" +"This tutorial aims to help you to learn how to develop plugins\n" +"which extends operations in handle phrase." +msgstr "" + +msgid "## Precondition" +msgstr "## 前提条件" + +msgid "* You must complete [Modify requests and responses tutorial][adapter]." +msgstr "" + +msgid "## Handling phase" +msgstr "" + +msgid "" +"The handling phase is the phase that the actual storage access is happen.\n" +"As Droonga is a distributed system, handler phase is done in multiple partitio" +"ns." +msgstr "" + +msgid "" +"Here, in this tutorial, we are going to replace the handling phase of `search`" +" command for explanation. This breaks the `search` command. So this is not use" +"ful in practice, but it will help you to learn how Droonga works." +msgstr "" + +msgid "" +"In practice, we need to *extend* Droonga. In this case, we need to add a new c" +"ommand which does not conflict with the existing commands. To do so, you need " +"to learn not only how to handle messages but also how to distribute messages t" +"o handlers and collect messages from them. Proceed to [Distribute requests and" +" collect responses][] after this tutorial completed." +msgstr "" + +msgid "TODO fix the link to \"Distribute requests and collect responses\" tutorial" +msgstr "" + +msgid "## Directory Structure" +msgstr "" + +msgid "" +"The directory structure for plugins are in same rule as explained in [Modify r" +"equests and responses tutorial][adapter]." +msgstr "" + +msgid "" +"Now let's create `sample-logger` plugin again. This will act almost same as [M" +"odify requests and responses tutorial][adapter] version, except the phase in w" +"hich the plugin works. We need to put `sample-logger.rb` to `lib/droonga/plugi" +"ns/sample-logger.rb`. The directory tree will be like this:" +msgstr "" + +msgid "" +"~~~\n" +"lib\n" +"└── droonga\n" +" └── plugins\n" +" └── sample-logger.rb\n" +"~~~" +msgstr "" + +msgid "## Create a plugin" +msgstr "" + +msgid "Create a plugin as follows:" +msgstr "" + +msgid "lib/droonga/plugins/sample-logger.rb:" +msgstr "" + +msgid "" +"~~~ruby\n" +"require \"droonga/plugin\"" +msgstr "" + +msgid "" +"module Droonga\n" +" module Plugins\n" +" module SampleLoggerPlugin\n" +" Plugin.registry.register(\"sample-logger\", self)" +msgstr "" + +msgid "" +" class Handler < Droonga::Handler\n" +" message.type = \"search\"" +msgstr "" + +msgid "" +" def handle(message, messenger)\n" +" $log.info \"Droonga::Plugins::SampleLoggerPlugin\", :message => messag" +"e\n" +" end\n" +" end\n" +" end\n" +" end\n" +"end\n" +"~~~" +msgstr "" + +msgid "## Activate the plugin with `catalog.json`" +msgstr "" + +msgid "" +"Update catalog.json to activate this plugin. Add `\"sample-logger\"` to `\"plugin" +"s\"`." +msgstr "" + +msgid "" +"~~~\n" +"(snip)\n" +" \"datasets\": {\n" +" \"Starbucks\": {\n" +" (snip)\n" +" \"plugins\": [\"sample-logger\", \"groonga\", \"crud\", \"search\"],\n" +"(snip)\n" +"~~~" +msgstr "" + +msgid "## Run" +msgstr "" + +msgid "" +"Let's get Droonga started. Note that you need to specify ./lib directory in RU" +"BYLIB environment variable in order to make ruby possible to find your plugin." +msgstr "" + +msgid "" +" # kill $(cat fluentd.pid)\n" +" # RUBYLIB=./lib fluentd --config fluentd.conf --log fluentd.log --daemon f" +"luentd.pid" +msgstr "" + +msgid "## Test" +msgstr "" + +msgid "" +"Send a search request to Droonga Engine. Use `search-columbus.json` same as of" +" [Modify requests and responses tutorial][adapter]." +msgstr "" + +msgid "" +"~~~\n" +"# droonga-request --tag starbucks search-columbus.json\n" +"~~~" +msgstr "" + +msgid "" +"You will see no output for `droonga-request` execution because out `sample-log" +"ger` plugin traps the `add` request." +msgstr "" + +msgid "Instead, you will see something like these lines in `fluentd.log`:" +msgstr "" + +msgid "" +"~~~\n" +"2014-02-17 16:25:23 +0900 [info]: Droonga::Plugins::SampleLoggerPlugin message" +"=#<Droonga::HandlerMessage:0x007f9a7f0987a8 @raw={\"dataset\"=>\"Starbucks\", \"typ" +"e\"=>\"search\", \"body\"=>{\"id\"=>\"localhost:24224/starbucks.#0\", \"task\"=>{\"route\"=" +">\"localhost:24224/starbucks.011\", \"step\"=>{\"command\"=>\"search\", \"dataset\"=>\"St" +"arbucks\", \"body\"=>{\"queries\"=>{\"stores\"=>{\"source\"=>\"Store\", \"condition\"=>{\"qu" +"ery\"=>\"Columbus\", \"matchTo\"=>\"_key\"}, \"output\"=>{\"elements\"=>[\"startTime\", \"el" +"apsedTime\", \"count\", \"attributes\", \"records\"], \"attributes\"=>[\"_key\"], \"limit\"" +"=>-1}}}}, \"type\"=>\"broadcast\", \"outputs\"=>[\"errors\", \"stores\"], \"replica\"=>\"ra" +"ndom\", \"routes\"=>[\"localhost:24224/starbucks.001\", \"localhost:24224/starbucks." +"011\", \"localhost:24224/starbucks.020\"], \"n_of_expects\"=>0, \"descendants\"=>{\"er" +"rors\"=>[\"localhost:24224/starbucks.#0\"], \"stores\"=>[\"localhost:24224/starbucks" +".#0\"]}}, \"n_of_inputs\"=>0, \"values\"=>{}}, \"descendants\"=>{\"errors\"=>[\"localhos" +"t:24224/starbucks\"], \"stores\"=>[\"localhost:24224/starbucks\"]}}, \"replyTo\"=>{\"t" +"ype\"=>\"search.result\", \"to\"=>\"127.0.0.1:50410/droonga\"}, \"id\"=>\"1392621923.903" +"868\", \"date\"=>\"2014-02-17 16:25:23 +0900\", \"appliedAdapters\"=>[\"Droonga::Plugi" +"ns::Error::Adapter\"]}, @body={\"id\"=>\"localhost:24224/starbucks.#0\", \"task\"=>{\"" +"route\"=>\"localhost:24224/starbucks.011\", \"step\"=>{\"command\"=>\"search\", \"datase" +"t\"=>\"Starbucks\", \"body\"=>{\"queries\"=>{\"stores\"=>{\"source\"=>\"Store\", \"condition" +"\"=>{\"query\"=>\"Columbus\", \"matchTo\"=>\"_key\"}, \"output\"=>{\"elements\"=>[\"startTim" +"e\", \"elapsedTime\", \"count\", \"attributes\", \"records\"], \"attributes\"=>[\"_key\"], " +"\"limit\"=>-1}}}}, \"type\"=>\"broadcast\", \"outputs\"=>[\"errors\", \"stores\"], \"replic" +"a\"=>\"random\", \"routes\"=>[\"localhost:24224/starbucks.001\", \"localhost:24224/sta" +"rbucks.011\", \"localhost:24224/starbucks.020\"], \"n_of_expects\"=>0, \"descendants" +"\"=>{\"errors\"=>[\"localhost:24224/starbucks.#0\"], \"stores\"=>[\"localhost:24224/st" +"arbucks.#0\"]}}, \"n_of_inputs\"=>0, \"values\"=>{}}, \"descendants\"=>{\"errors\"=>[\"l" +"ocalhost:24224/starbucks\"], \"stores\"=>[\"localhost:24224/starbucks\"]}}, @task={" +"\"route\"=>\"localhost:24224/starbucks.011\", \"step\"=>{\"command\"=>\"search\", \"datas" +"et\"=>\"Starbucks\", \"body\"=>{\"queries\"=>{\"stores\"=>{\"source\"=>\"Store\", \"conditio" +"n\"=>{\"query\"=>\"Columbus\", \"matchTo\"=>\"_key\"}, \"output\"=>{\"elements\"=>[\"startTi" +"me\", \"elapsedTime\", \"count\", \"attributes\", \"records\"], \"attributes\"=>[\"_key\"]," +" \"limit\"=>-1}}}}, \"type\"=>\"broadcast\", \"outputs\"=>[\"errors\", \"stores\"], \"repli" +"ca\"=>\"random\", \"routes\"=>[\"localhost:24224/starbucks.001\", \"localhost:24224/st" +"arbucks.011\", \"localhost:24224/starbucks.020\"], \"n_of_expects\"=>0, \"descendant" +"s\"=>{\"errors\"=>[\"localhost:24224/starbucks.#0\"], \"stores\"=>[\"localhost:24224/s" +"tarbucks.#0\"]}}, \"n_of_inputs\"=>0, \"values\"=>{}}, @step={\"command\"=>\"search\", " +"\"dataset\"=>\"Starbucks\", \"body\"=>{\"queries\"=>{\"stores\"=>{\"source\"=>\"Store\", \"co" +"ndition\"=>{\"query\"=>\"Columbus\", \"matchTo\"=>\"_key\"}, \"output\"=>{\"elements\"=>[\"s" +"tartTime\", \"elapsedTime\", \"count\", \"attributes\", \"records\"], \"attributes\"=>[\"_" +"key\"], \"limit\"=>-1}}}}, \"type\"=>\"broadcast\", \"outputs\"=>[\"errors\", \"stores\"], " +"\"replica\"=>\"random\", \"routes\"=>[\"localhost:24224/starbucks.001\", \"localhost:24" +"224/starbucks.011\", \"localhost:24224/starbucks.020\"], \"n_of_expects\"=>0, \"desc" +"endants\"=>{\"errors\"=>[\"localhost:24224/starbucks.#0\"], \"stores\"=>[\"localhost:2" +"4224/starbucks.#0\"]}}>\n" +"2014-02-17 16:25:23 +0900 [info]: Droonga::Plugins::SampleLoggerPlugin message" +"=#<Droonga::HandlerMessage:0x007f9a7f060970 @raw={\"dataset\"=>\"Starbucks\", \"typ" +"e\"=>\"search\", \"body\"=>{\"id\"=>\"localhost:24224/starbucks.#0\", \"task\"=>{\"route\"=" +">\"localhost:24224/starbucks.020\", \"step\"=>{\"command\"=>\"search\", \"dataset\"=>\"St" +"arbucks\", \"body\"=>{\"queries\"=>{\"stores\"=>{\"source\"=>\"Store\", \"condition\"=>{\"qu" +"ery\"=>\"Columbus\", \"matchTo\"=>\"_key\"}, \"output\"=>{\"elements\"=>[\"startTime\", \"el" +"apsedTime\", \"count\", \"attributes\", \"records\"], \"attributes\"=>[\"_key\"], \"limit\"" +"=>-1}}}}, \"type\"=>\"broadcast\", \"outputs\"=>[\"errors\", \"stores\"], \"replica\"=>\"ra" +"ndom\", \"routes\"=>[\"localhost:24224/starbucks.001\", \"localhost:24224/starbucks." +"011\", \"localhost:24224/starbucks.020\"], \"n_of_expects\"=>0, \"descendants\"=>{\"er" +"rors\"=>[\"localhost:24224/starbucks.#0\"], \"stores\"=>[\"localhost:24224/starbucks" +".#0\"]}}, \"n_of_inputs\"=>0, \"values\"=>{}}, \"descendants\"=>{\"errors\"=>[\"localhos" +"t:24224/starbucks\"], \"stores\"=>[\"localhost:24224/starbucks\"]}}, \"replyTo\"=>{\"t" +"ype\"=>\"search.result\", \"to\"=>\"127.0.0.1:50410/droonga\"}, \"id\"=>\"1392621923.903" +"868\", \"date\"=>\"2014-02-17 16:25:23 +0900\", \"appliedAdapters\"=>[\"Droonga::Plugi" +"ns::Error::Adapter\"]}, @body={\"id\"=>\"localhost:24224/starbucks.#0\", \"task\"=>{\"" +"route\"=>\"localhost:24224/starbucks.020\", \"step\"=>{\"command\"=>\"search\", \"datase" +"t\"=>\"Starbucks\", \"body\"=>{\"queries\"=>{\"stores\"=>{\"source\"=>\"Store\", \"condition" +"\"=>{\"query\"=>\"Columbus\", \"matchTo\"=>\"_key\"}, \"output\"=>{\"elements\"=>[\"startTim" +"e\", \"elapsedTime\", \"count\", \"attributes\", \"records\"], \"attributes\"=>[\"_key\"], " +"\"limit\"=>-1}}}}, \"type\"=>\"broadcast\", \"outputs\"=>[\"errors\", \"stores\"], \"replic" +"a\"=>\"random\", \"routes\"=>[\"localhost:24224/starbucks.001\", \"localhost:24224/sta" +"rbucks.011\", \"localhost:24224/starbucks.020\"], \"n_of_expects\"=>0, \"descendants" +"\"=>{\"errors\"=>[\"localhost:24224/starbucks.#0\"], \"stores\"=>[\"localhost:24224/st" +"arbucks.#0\"]}}, \"n_of_inputs\"=>0, \"values\"=>{}}, \"descendants\"=>{\"errors\"=>[\"l" +"ocalhost:24224/starbucks\"], \"stores\"=>[\"localhost:24224/starbucks\"]}}, @task={" +"\"route\"=>\"localhost:24224/starbucks.020\", \"step\"=>{\"command\"=>\"search\", \"datas" +"et\"=>\"Starbucks\", \"body\"=>{\"queries\"=>{\"stores\"=>{\"source\"=>\"Store\", \"conditio" +"n\"=>{\"query\"=>\"Columbus\", \"matchTo\"=>\"_key\"}, \"output\"=>{\"elements\"=>[\"startTi" +"me\", \"elapsedTime\", \"count\", \"attributes\", \"records\"], \"attributes\"=>[\"_key\"]," +" \"limit\"=>-1}}}}, \"type\"=>\"broadcast\", \"outputs\"=>[\"errors\", \"stores\"], \"repli" +"ca\"=>\"random\", \"routes\"=>[\"localhost:24224/starbucks.001\", \"localhost:24224/st" +"arbucks.011\", \"localhost:24224/starbucks.020\"], \"n_of_expects\"=>0, \"descendant" +"s\"=>{\"errors\"=>[\"localhost:24224/starbucks.#0\"], \"stores\"=>[\"localhost:24224/s" +"tarbucks.#0\"]}}, \"n_of_inputs\"=>0, \"values\"=>{}}, @step={\"command\"=>\"search\", " +"\"dataset\"=>\"Starbucks\", \"body\"=>{\"queries\"=>{\"stores\"=>{\"source\"=>\"Store\", \"co" +"ndition\"=>{\"query\"=>\"Columbus\", \"matchTo\"=>\"_key\"}, \"output\"=>{\"elements\"=>[\"s" +"tartTime\", \"elapsedTime\", \"count\", \"attributes\", \"records\"], \"attributes\"=>[\"_" +"key\"], \"limit\"=>-1}}}}, \"type\"=>\"broadcast\", \"outputs\"=>[\"errors\", \"stores\"], " +"\"replica\"=>\"random\", \"routes\"=>[\"localhost:24224/starbucks.001\", \"localhost:24" +"224/starbucks.011\", \"localhost:24224/starbucks.020\"], \"n_of_expects\"=>0, \"desc" +"endants\"=>{\"errors\"=>[\"localhost:24224/starbucks.#0\"], \"stores\"=>[\"localhost:2" +"4224/starbucks.#0\"]}}>\n" +"2014-02-17 16:25:23 +0900 [info]: Droonga::Plugins::SampleLoggerPlugin message" +"=#<Droonga::HandlerMessage:0x007f9a7f069c50 @raw={\"dataset\"=>\"Starbucks\", \"typ" +"e\"=>\"search\", \"body\"=>{\"id\"=>\"localhost:24224/starbucks.#0\", \"task\"=>{\"route\"=" +">\"localhost:24224/starbucks.001\", \"step\"=>{\"command\"=>\"search\", \"dataset\"=>\"St" +"arbucks\", \"body\"=>{\"queries\"=>{\"stores\"=>{\"source\"=>\"Store\", \"condition\"=>{\"qu" +"ery\"=>\"Columbus\", \"matchTo\"=>\"_key\"}, \"output\"=>{\"elements\"=>[\"startTime\", \"el" +"apsedTime\", \"count\", \"attributes\", \"records\"], \"attributes\"=>[\"_key\"], \"limit\"" +"=>-1}}}}, \"type\"=>\"broadcast\", \"outputs\"=>[\"errors\", \"stores\"], \"replica\"=>\"ra" +"ndom\", \"routes\"=>[\"localhost:24224/starbucks.001\", \"localhost:24224/starbucks." +"011\", \"localhost:24224/starbucks.020\"], \"n_of_expects\"=>0, \"descendants\"=>{\"er" +"rors\"=>[\"localhost:24224/starbucks.#0\"], \"stores\"=>[\"localhost:24224/starbucks" +".#0\"]}}, \"n_of_inputs\"=>0, \"values\"=>{}}, \"descendants\"=>{\"errors\"=>[\"localhos" +"t:24224/starbucks\"], \"stores\"=>[\"localhost:24224/starbucks\"]}}, \"replyTo\"=>{\"t" +"ype\"=>\"search.result\", \"to\"=>\"127.0.0.1:50410/droonga\"}, \"id\"=>\"1392621923.903" +"868\", \"date\"=>\"2014-02-17 16:25:23 +0900\", \"appliedAdapters\"=>[\"Droonga::Plugi" +"ns::Error::Adapter\"]}, @body={\"id\"=>\"localhost:24224/starbucks.#0\", \"task\"=>{\"" +"route\"=>\"localhost:24224/starbucks.001\", \"step\"=>{\"command\"=>\"search\", \"datase" +"t\"=>\"Starbucks\", \"body\"=>{\"queries\"=>{\"stores\"=>{\"source\"=>\"Store\", \"condition" +"\"=>{\"query\"=>\"Columbus\", \"matchTo\"=>\"_key\"}, \"output\"=>{\"elements\"=>[\"startTim" +"e\", \"elapsedTime\", \"count\", \"attributes\", \"records\"], \"attributes\"=>[\"_key\"], " +"\"limit\"=>-1}}}}, \"type\"=>\"broadcast\", \"outputs\"=>[\"errors\", \"stores\"], \"replic" +"a\"=>\"random\", \"routes\"=>[\"localhost:24224/starbucks.001\", \"localhost:24224/sta" +"rbucks.011\", \"localhost:24224/starbucks.020\"], \"n_of_expects\"=>0, \"descendants" +"\"=>{\"errors\"=>[\"localhost:24224/starbucks.#0\"], \"stores\"=>[\"localhost:24224/st" +"arbucks.#0\"]}}, \"n_of_inputs\"=>0, \"values\"=>{}}, \"descendants\"=>{\"errors\"=>[\"l" +"ocalhost:24224/starbucks\"], \"stores\"=>[\"localhost:24224/starbucks\"]}}, @task={" +"\"route\"=>\"localhost:24224/starbucks.001\", \"step\"=>{\"command\"=>\"search\", \"datas" +"et\"=>\"Starbucks\", \"body\"=>{\"queries\"=>{\"stores\"=>{\"source\"=>\"Store\", \"conditio" +"n\"=>{\"query\"=>\"Columbus\", \"matchTo\"=>\"_key\"}, \"output\"=>{\"elements\"=>[\"startTi" +"me\", \"elapsedTime\", \"count\", \"attributes\", \"records\"], \"attributes\"=>[\"_key\"]," +" \"limit\"=>-1}}}}, \"type\"=>\"broadcast\", \"outputs\"=>[\"errors\", \"stores\"], \"repli" +"ca\"=>\"random\", \"routes\"=>[\"localhost:24224/starbucks.001\", \"localhost:24224/st" +"arbucks.011\", \"localhost:24224/starbucks.020\"], \"n_of_expects\"=>0, \"descendant" +"s\"=>{\"errors\"=>[\"localhost:24224/starbucks.#0\"], \"stores\"=>[\"localhost:24224/s" +"tarbucks.#0\"]}}, \"n_of_inputs\"=>0, \"values\"=>{}}, @step={\"command\"=>\"search\", " +"\"dataset\"=>\"Starbucks\", \"body\"=>{\"queries\"=>{\"stores\"=>{\"source\"=>\"Store\", \"co" +"ndition\"=>{\"query\"=>\"Columbus\", \"matchTo\"=>\"_key\"}, \"output\"=>{\"elements\"=>[\"s" +"tartTime\", \"elapsedTime\", \"count\", \"attributes\", \"records\"], \"attributes\"=>[\"_" +"key\"], \"limit\"=>-1}}}}, \"type\"=>\"broadcast\", \"outputs\"=>[\"errors\", \"stores\"], " +"\"replica\"=>\"random\", \"routes\"=>[\"localhost:24224/starbucks.001\", \"localhost:24" +"224/starbucks.011\", \"localhost:24224/starbucks.020\"], \"n_of_expects\"=>0, \"desc" +"endants\"=>{\"errors\"=>[\"localhost:24224/starbucks.#0\"], \"stores\"=>[\"localhost:2" +"4224/starbucks.#0\"]}}>\n" +"~~~" +msgstr "" + +msgid "Note that three lines are shown for only one request. What is happening?" +msgstr "" + +msgid "" +"Remember that we have configured `Starbucks` dataset to use three partitions (" +"and each has two replicas) in `catalog.json` of [the basic tutorial][basic]." +msgstr "" + +msgid "" +"The `search` request is dispatched to three partitions and passed into handlin" +"g phase for each partition. That is because we saw three lines for one request" +"." +msgstr "" + +msgid "" +"The messages shown is in internal format, which is transformed from the reques" +"t you've sent.\n" +"You can see your search request is distributed to partitions `localhost:24224/" +"starbucks.000`, `localhost:24224/starbucks.010` and `localhost:24224/starbucks" +".021` from `\"routes\"`." +msgstr "" + +msgid "" +"In `search` case, it is enough to use one replica per one partition because re" +"plicas for a partition are expected to have the exactly same contents.\n" +"So the planner ordered distributor to choose one replica randomly." +msgstr "" + +msgid "## Trap \"add\" command" +msgstr "" + +msgid "" +"We have seen how distributed search is done from the view point of handling ph" +"ase so far.\n" +"How about `\"add\"` command?" +msgstr "" + +msgid "Update `smaple-logger` plugin to trap `\"add\"` message instead of `\"search\"`." +msgstr "" + +msgid "" +"~~~\n" +"require \"droonga/plugin\"" +msgstr "" + +msgid "" +" class Handler < Droonga::Handler\n" +" message.type = \"add\" # This was \"search\" in the previous version." +msgstr "" + +msgid "Restart `fluentd`:" +msgstr "" + +msgid "" +"~~~\n" +"# kill $(cat fluentd.pid)\n" +"# RUBYLIB=./lib fluentd --config fluentd.conf --log fluentd.log --daemon fluen" +"td.pid\n" +"~~~" +msgstr "" + +msgid "" +"Let's send a request to Droonga Engine.\n" +"Here, we use the first line of `stores.json`." +msgstr "" + +msgid "add-store.json:" +msgstr "" + +msgid "" +"~~~\n" +"{\"dataset\":\"Starbucks\",\"type\":\"add\",\"body\":{\"table\":\"Store\",\"key\":\"1st Avenue " +"& 75th St. - New York NY (W)\",\"values\":{\"location\":\"40.770262,-73.954798\"}}}\n" +"~~~" +msgstr "" + +msgid "Send it to the engine:" +msgstr "" + +msgid "" +"~~~\n" +"# droonga-request --tag starbucks add-store.json\n" +"~~~" +msgstr "" + +msgid "Instead, you will see results like this in `fluentd.log`:" +msgstr "" + +msgid "" +"~~~\n" +"2014-02-17 16:29:18 +0900 [info]: Droonga::Plugins::SampleLoggerPlugin message" +"=#<Droonga::HandlerMessage:0x007f7f6a66c4c0 @raw={\"dataset\"=>\"Starbucks\", \"typ" +"e\"=>\"add\", \"body\"=>{\"id\"=>\"localhost:24224/starbucks.#2\", \"task\"=>{\"route\"=>\"l" +"ocalhost:24224/starbucks.000\", \"step\"=>{\"command\"=>\"add\", \"dataset\"=>\"Starbuck" +"s\", \"body\"=>{\"table\"=>\"Store\", \"key\"=>\"1st Avenue & 75th St. - New York NY (W" +")\", \"values\"=>{\"location\"=>\"40.770262,-73.954798\"}}, \"key\"=>\"1st Avenue & 75th" +" St. - New York NY (W)\", \"type\"=>\"scatter\", \"outputs\"=>[\"errors\", \"success\"]," +" \"replica\"=>\"all\", \"post\"=>true, \"routes\"=>[\"localhost:24224/starbucks.000\", \"" +"localhost:24224/starbucks.001\"], \"n_of_expects\"=>0, \"descendants\"=>{\"errors\"=>" +"[\"localhost:24224/starbucks.#2\"], \"success\"=>[\"localhost:24224/starbucks.#2\"]}" +"}, \"n_of_inputs\"=>0, \"values\"=>{}}, \"descendants\"=>{\"errors\"=>[\"localhost:2422" +"4/starbucks\"], \"success\"=>[\"localhost:24224/starbucks\"]}}, \"replyTo\"=>{\"type\"=" +">\"add.result\", \"to\"=>\"127.0.0.1:50480/droonga\"}, \"id\"=>\"1392622158.374441\", \"d" +"ate\"=>\"2014-02-17 16:29:18 +0900\", \"appliedAdapters\"=>[\"Droonga::Plugins::CRUD" +"::Adapter\", \"Droonga::Plugins::Error::Adapter\"]}, @body={\"id\"=>\"localhost:2422" +"4/starbucks.#2\", \"task\"=>{\"route\"=>\"localhost:24224/starbucks.000\", \"step\"=>{\"" +"command\"=>\"add\", \"dataset\"=>\"Starbucks\", \"body\"=>{\"table\"=>\"Store\", \"key\"=>\"1s" +"t Avenue & 75th St. - New York NY (W)\", \"values\"=>{\"location\"=>\"40.770262,-73" +".954798\"}}, \"key\"=>\"1st Avenue & 75th St. - New York NY (W)\", \"type\"=>\"scatte" +"r\", \"outputs\"=>[\"errors\", \"success\"], \"replica\"=>\"all\", \"post\"=>true, \"routes\"" +"=>[\"localhost:24224/starbucks.000\", \"localhost:24224/starbucks.001\"], \"n_of_ex" +"pects\"=>0, \"descendants\"=>{\"errors\"=>[\"localhost:24224/starbucks.#2\"], \"succes" +"s\"=>[\"localhost:24224/starbucks.#2\"]}}, \"n_of_inputs\"=>0, \"values\"=>{}}, \"desc" +"endants\"=>{\"errors\"=>[\"localhost:24224/starbucks\"], \"success\"=>[\"localhost:242" +"24/starbucks\"]}}, @task={\"route\"=>\"localhost:24224/starbucks.000\", \"step\"=>{\"c" +"ommand\"=>\"add\", \"dataset\"=>\"Starbucks\", \"body\"=>{\"table\"=>\"Store\", \"key\"=>\"1st" +" Avenue & 75th St. - New York NY (W)\", \"values\"=>{\"location\"=>\"40.770262,-73." +"954798\"}}, \"key\"=>\"1st Avenue & 75th St. - New York NY (W)\", \"type\"=>\"scatter" +"\", \"outputs\"=>[\"errors\", \"success\"], \"replica\"=>\"all\", \"post\"=>true, \"routes\"=" +">[\"localhost:24224/starbucks.000\", \"localhost:24224/starbucks.001\"], \"n_of_exp" +"ects\"=>0, \"descendants\"=>{\"errors\"=>[\"localhost:24224/starbucks.#2\"], \"success" +"\"=>[\"localhost:24224/starbucks.#2\"]}}, \"n_of_inputs\"=>0, \"values\"=>{}}, @step=" +"{\"command\"=>\"add\", \"dataset\"=>\"Starbucks\", \"body\"=>{\"table\"=>\"Store\", \"key\"=>\"" +"1st Avenue & 75th St. - New York NY (W)\", \"values\"=>{\"location\"=>\"40.770262,-" +"73.954798\"}}, \"key\"=>\"1st Avenue & 75th St. - New York NY (W)\", \"type\"=>\"scat" +"ter\", \"outputs\"=>[\"errors\", \"success\"], \"replica\"=>\"all\", \"post\"=>true, \"route" +"s\"=>[\"localhost:24224/starbucks.000\", \"localhost:24224/starbucks.001\"], \"n_of_" +"expects\"=>0, \"descendants\"=>{\"errors\"=>[\"localhost:24224/starbucks.#2\"], \"succ" +"ess\"=>[\"localhost:24224/starbucks.#2\"]}}>\n" +"2014-02-17 16:29:18 +0900 [info]: Droonga::Plugins::SampleLoggerPlugin message" +"=#<Droonga::HandlerMessage:0x007f7f6a65ff40 @raw={\"dataset\"=>\"Starbucks\", \"typ" +"e\"=>\"add\", \"body\"=>{\"id\"=>\"localhost:24224/starbucks.#2\", \"task\"=>{\"route\"=>\"l" +"ocalhost:24224/starbucks.001\", \"step\"=>{\"command\"=>\"add\", \"dataset\"=>\"Starbuck" +"s\", \"body\"=>{\"table\"=>\"Store\", \"key\"=>\"1st Avenue & 75th St. - New York NY (W" +")\", \"values\"=>{\"location\"=>\"40.770262,-73.954798\"}}, \"key\"=>\"1st Avenue & 75th" +" St. - New York NY (W)\", \"type\"=>\"scatter\", \"outputs\"=>[\"errors\", \"success\"]," +" \"replica\"=>\"all\", \"post\"=>true, \"routes\"=>[\"localhost:24224/starbucks.000\", \"" +"localhost:24224/starbucks.001\"], \"n_of_expects\"=>0, \"descendants\"=>{\"errors\"=>" +"[\"localhost:24224/starbucks.#2\"], \"success\"=>[\"localhost:24224/starbucks.#2\"]}" +"}, \"n_of_inputs\"=>0, \"values\"=>{}}, \"descendants\"=>{\"errors\"=>[\"localhost:2422" +"4/starbucks\"], \"success\"=>[\"localhost:24224/starbucks\"]}}, \"replyTo\"=>{\"type\"=" +">\"add.result\", \"to\"=>\"127.0.0.1:50480/droonga\"}, \"id\"=>\"1392622158.374441\", \"d" +"ate\"=>\"2014-02-17 16:29:18 +0900\", \"appliedAdapters\"=>[\"Droonga::Plugins::CRUD" +"::Adapter\", \"Droonga::Plugins::Error::Adapter\"]}, @body={\"id\"=>\"localhost:2422" +"4/starbucks.#2\", \"task\"=>{\"route\"=>\"localhost:24224/starbucks.001\", \"step\"=>{\"" +"command\"=>\"add\", \"dataset\"=>\"Starbucks\", \"body\"=>{\"table\"=>\"Store\", \"key\"=>\"1s" +"t Avenue & 75th St. - New York NY (W)\", \"values\"=>{\"location\"=>\"40.770262,-73" +".954798\"}}, \"key\"=>\"1st Avenue & 75th St. - New York NY (W)\", \"type\"=>\"scatte" +"r\", \"outputs\"=>[\"errors\", \"success\"], \"replica\"=>\"all\", \"post\"=>true, \"routes\"" +"=>[\"localhost:24224/starbucks.000\", \"localhost:24224/starbucks.001\"], \"n_of_ex" +"pects\"=>0, \"descendants\"=>{\"errors\"=>[\"localhost:24224/starbucks.#2\"], \"succes" +"s\"=>[\"localhost:24224/starbucks.#2\"]}}, \"n_of_inputs\"=>0, \"values\"=>{}}, \"desc" +"endants\"=>{\"errors\"=>[\"localhost:24224/starbucks\"], \"success\"=>[\"localhost:242" +"24/starbucks\"]}}, @task={\"route\"=>\"localhost:24224/starbucks.001\", \"step\"=>{\"c" +"ommand\"=>\"add\", \"dataset\"=>\"Starbucks\", \"body\"=>{\"table\"=>\"Store\", \"key\"=>\"1st" +" Avenue & 75th St. - New York NY (W)\", \"values\"=>{\"location\"=>\"40.770262,-73." +"954798\"}}, \"key\"=>\"1st Avenue & 75th St. - New York NY (W)\", \"type\"=>\"scatter" +"\", \"outputs\"=>[\"errors\", \"success\"], \"replica\"=>\"all\", \"post\"=>true, \"routes\"=" +">[\"localhost:24224/starbucks.000\", \"localhost:24224/starbucks.001\"], \"n_of_exp" +"ects\"=>0, \"descendants\"=>{\"errors\"=>[\"localhost:24224/starbucks.#2\"], \"success" +"\"=>[\"localhost:24224/starbucks.#2\"]}}, \"n_of_inputs\"=>0, \"values\"=>{}}, @step=" +"{\"command\"=>\"add\", \"dataset\"=>\"Starbucks\", \"body\"=>{\"table\"=>\"Store\", \"key\"=>\"" +"1st Avenue & 75th St. - New York NY (W)\", \"values\"=>{\"location\"=>\"40.770262,-" +"73.954798\"}}, \"key\"=>\"1st Avenue & 75th St. - New York NY (W)\", \"type\"=>\"scat" +"ter\", \"outputs\"=>[\"errors\", \"success\"], \"replica\"=>\"all\", \"post\"=>true, \"route" +"s\"=>[\"localhost:24224/starbucks.000\", \"localhost:24224/starbucks.001\"], \"n_of_" +"expects\"=>0, \"descendants\"=>{\"errors\"=>[\"localhost:24224/starbucks.#2\"], \"succ" +"ess\"=>[\"localhost:24224/starbucks.#2\"]}}>\n" +"~~~" +msgstr "" + +msgid "" +"In `add` case, two log lines are shown for one request. This is because we hav" +"e configured to have two replicas for each partition." +msgstr "" + +msgid "" +"In order to be consistent, `add` command must reach all of the replicas of the" +" partition, but not the other partitions.\n" +"As a consequence, `localhost:24224/starbucks.000` and `localhost:24224/starbuc" +"ks.001` are chosen." +msgstr "" + +msgid "## Conclusion" +msgstr "## まとめ" + +msgid "We have learned how to create plugins work in handling phrase." +msgstr "" + +msgid "" +" [adapter]: ../adapter\n" +" [basic]: ../basic" +msgstr "" Modified: ja/tutorial/basic/index.md (+714 -58) =================================================================== --- ja/tutorial/basic/index.md 2014-02-17 16:32:06 +0900 (348b143) +++ ja/tutorial/basic/index.md 2014-02-17 16:36:15 +0900 (33d9d22) @@ -88,9 +88,9 @@ Droonga をセットアップするために必要になるパッケージをイ Droonga Engine は、データベースを保持し、実際の検索を担当する部分です。 このセクションでは、 fluent-plugin-droonga をインストールし、検索対象となるデータを準備します。 -### fluent-plugin-droonga をインストールする +### fluent-plugin-droongaとdroonga-clientをインストールする - # gem install fluent-plugin-droonga + # gem install fluent-plugin-droonga droonga-client Droonga Engine を構築するのに必要なパッケージがセットアップできました。引き続き設定に移ります。 @@ -219,67 +219,723 @@ Dronga Engine が起動したので、データを投入しましょう。 ddl.jsons: - {"id":"ddl:0","dataset":"Starbucks","type":"table_create","replyTo":"localhost:24224/output","body":{"name":"Store","flags":"TABLE_HASH_KEY","key_type":"ShortText"}} - {"id":"ddl:1","dataset":"Starbucks","type":"column_create","replyTo":"localhost:24224/output","body":{"table":"Store","name":"location","flags":"COLUMN_SCALAR","type":"WGS84GeoPoint"}} - {"id":"ddl:2","dataset":"Starbucks","type":"table_create","replyTo":"localhost:24224/output","body":{"name":"Location","flags":"TABLE_PAT_KEY","key_type":"WGS84GeoPoint"}} - {"id":"ddl:3","dataset":"Starbucks","type":"column_create","replyTo":"localhost:24224/output","body":{"table":"Location","name":"store","flags":"COLUMN_INDEX","type":"Store","source":"location"}} - {"id":"ddl:4","dataset":"Starbucks","type":"table_create","replyTo":"localhost:24224/output","body":{"name":"Term","flags":"TABLE_PAT_KEY","key_type":"ShortText","default_tokenizer":"TokenBigram","normalizer":"NormalizerAuto"}} - {"id":"ddl:5","dataset":"Starbucks","type":"column_create","replyTo":"localhost:24224/output","body":{"table":"Term","name":"stores__key","flags":"COLUMN_INDEX|WITH_POSITION","type":"Store","source":"_key"}} +~~~ +{"dataset":"Starbucks","type":"table_create","body":{"name":"Store","flags":"TABLE_HASH_KEY","key_type":"ShortText"}} +{"dataset":"Starbucks","type":"column_create","body":{"table":"Store","name":"location","flags":"COLUMN_SCALAR","type":"WGS84GeoPoint"}} +{"dataset":"Starbucks","type":"table_create","body":{"name":"Location","flags":"TABLE_PAT_KEY","key_type":"WGS84GeoPoint"}} +{"dataset":"Starbucks","type":"column_create","body":{"table":"Location","name":"store","flags":"COLUMN_INDEX","type":"Store","source":"location"}} +{"dataset":"Starbucks","type":"table_create","body":{"name":"Term","flags":"TABLE_PAT_KEY","key_type":"ShortText","default_tokenizer":"TokenBigram","normalizer":"NormalizerAuto"}} +{"dataset":"Starbucks","type":"column_create","body":{"table":"Term","name":"stores__key","flags":"COLUMN_INDEX|WITH_POSITION","type":"Store","source":"_key"}} +~~~ stores.jsons: - {"id":"stores:0","replyTo":"localhost:24224/output","dataset":"Starbucks","type":"add","body":{"table":"Store","key":"1st Avenue & 75th St. - New York NY (W)","values":{"location":"40.770262,-73.954798"}}} - {"id":"stores:1","replyTo":"localhost:24224/output","dataset":"Starbucks","type":"add","body":{"table":"Store","key":"76th & Second - New York NY (W)","values":{"location":"40.771056,-73.956757"}}} - {"id":"stores:2","replyTo":"localhost:24224/output","dataset":"Starbucks","type":"add","body":{"table":"Store","key":"2nd Ave. & 9th Street - New York NY","values":{"location":"40.729445,-73.987471"}}} - {"id":"stores:3","replyTo":"localhost:24224/output","dataset":"Starbucks","type":"add","body":{"table":"Store","key":"15th & Third - New York NY (W)","values":{"location":"40.733946,-73.9867"}}} - {"id":"stores:4","replyTo":"localhost:24224/output","dataset":"Starbucks","type":"add","body":{"table":"Store","key":"41st and Broadway - New York NY (W)","values":{"location":"40.755111,-73.986225"}}} - {"id":"stores:5","replyTo":"localhost:24224/output","dataset":"Starbucks","type":"add","body":{"table":"Store","key":"84th & Third Ave - New York NY (W)","values":{"location":"40.777485,-73.954979"}}} - {"id":"stores:6","replyTo":"localhost:24224/output","dataset":"Starbucks","type":"add","body":{"table":"Store","key":"150 E. 42nd Street - New York NY (W)","values":{"location":"40.750784,-73.975582"}}} - {"id":"stores:7","replyTo":"localhost:24224/output","dataset":"Starbucks","type":"add","body":{"table":"Store","key":"West 43rd and Broadway - New York NY (W)","values":{"location":"40.756197,-73.985624"}}} - {"id":"stores:8","replyTo":"localhost:24224/output","dataset":"Starbucks","type":"add","body":{"table":"Store","key":"Macy's 35th Street Balcony - New York NY","values":{"location":"40.750703,-73.989787"}}} - {"id":"stores:9","replyTo":"localhost:24224/output","dataset":"Starbucks","type":"add","body":{"table":"Store","key":"Macy's 6th Floor - Herald Square - New York NY (W)","values":{"location":"40.750703,-73.989787"}}} - {"id":"stores:10","replyTo":"localhost:24224/output","dataset":"Starbucks","type":"add","body":{"table":"Store","key":"Herald Square- Macy's - New York NY","values":{"location":"40.750703,-73.989787"}}} - {"id":"stores:11","replyTo":"localhost:24224/output","dataset":"Starbucks","type":"add","body":{"table":"Store","key":"Macy's 5th Floor - Herald Square - New York NY (W)","values":{"location":"40.750703,-73.989787"}}} - {"id":"stores:12","replyTo":"localhost:24224/output","dataset":"Starbucks","type":"add","body":{"table":"Store","key":"80th & York - New York NY (W)","values":{"location":"40.772204,-73.949862"}}} - {"id":"stores:13","replyTo":"localhost:24224/output","dataset":"Starbucks","type":"add","body":{"table":"Store","key":"Columbus @ 67th - New York NY (W)","values":{"location":"40.774009,-73.981472"}}} - {"id":"stores:14","replyTo":"localhost:24224/output","dataset":"Starbucks","type":"add","body":{"table":"Store","key":"45th & Broadway - New York NY (W)","values":{"location":"40.75766,-73.985719"}}} - {"id":"stores:15","replyTo":"localhost:24224/output","dataset":"Starbucks","type":"add","body":{"table":"Store","key":"Marriott Marquis - Lobby - New York NY","values":{"location":"40.759123,-73.984927"}}} - {"id":"stores:16","replyTo":"localhost:24224/output","dataset":"Starbucks","type":"add","body":{"table":"Store","key":"Second @ 81st - New York NY (W)","values":{"location":"40.77466,-73.954447"}}} - {"id":"stores:17","replyTo":"localhost:24224/output","dataset":"Starbucks","type":"add","body":{"table":"Store","key":"52nd & Seventh - New York NY (W)","values":{"location":"40.761829,-73.981141"}}} - {"id":"stores:18","replyTo":"localhost:24224/output","dataset":"Starbucks","type":"add","body":{"table":"Store","key":"1585 Broadway (47th) - New York NY (W)","values":{"location":"40.759806,-73.985066"}}} - {"id":"stores:19","replyTo":"localhost:24224/output","dataset":"Starbucks","type":"add","body":{"table":"Store","key":"85th & First - New York NY (W)","values":{"location":"40.776101,-73.949971"}}} - {"id":"stores:20","replyTo":"localhost:24224/output","dataset":"Starbucks","type":"add","body":{"table":"Store","key":"92nd & 3rd - New York NY (W)","values":{"location":"40.782606,-73.951235"}}} - {"id":"stores:21","replyTo":"localhost:24224/output","dataset":"Starbucks","type":"add","body":{"table":"Store","key":"165 Broadway - 1 Liberty - New York NY (W)","values":{"location":"40.709727,-74.011395"}}} - {"id":"stores:22","replyTo":"localhost:24224/output","dataset":"Starbucks","type":"add","body":{"table":"Store","key":"1656 Broadway - New York NY (W)","values":{"location":"40.762434,-73.983364"}}} - {"id":"stores:23","replyTo":"localhost:24224/output","dataset":"Starbucks","type":"add","body":{"table":"Store","key":"54th & Broadway - New York NY (W)","values":{"location":"40.764275,-73.982361"}}} - {"id":"stores:24","replyTo":"localhost:24224/output","dataset":"Starbucks","type":"add","body":{"table":"Store","key":"Limited Brands-NYC - New York NY","values":{"location":"40.765219,-73.982025"}}} - {"id":"stores:25","replyTo":"localhost:24224/output","dataset":"Starbucks","type":"add","body":{"table":"Store","key":"19th & 8th - New York NY (W)","values":{"location":"40.743218,-74.000605"}}} - {"id":"stores:26","replyTo":"localhost:24224/output","dataset":"Starbucks","type":"add","body":{"table":"Store","key":"60th & Broadway-II - New York NY (W)","values":{"location":"40.769196,-73.982576"}}} - {"id":"stores:27","replyTo":"localhost:24224/output","dataset":"Starbucks","type":"add","body":{"table":"Store","key":"63rd & Broadway - New York NY (W)","values":{"location":"40.771376,-73.982709"}}} - {"id":"stores:28","replyTo":"localhost:24224/output","dataset":"Starbucks","type":"add","body":{"table":"Store","key":"195 Broadway - New York NY (W)","values":{"location":"40.710703,-74.009485"}}} - {"id":"stores:29","replyTo":"localhost:24224/output","dataset":"Starbucks","type":"add","body":{"table":"Store","key":"2 Broadway - New York NY (W)","values":{"location":"40.704538,-74.01324"}}} - {"id":"stores:30","replyTo":"localhost:24224/output","dataset":"Starbucks","type":"add","body":{"table":"Store","key":"2 Columbus Ave. - New York NY (W)","values":{"location":"40.769262,-73.984764"}}} - {"id":"stores:31","replyTo":"localhost:24224/output","dataset":"Starbucks","type":"add","body":{"table":"Store","key":"NY Plaza - New York NY (W)","values":{"location":"40.702802,-74.012784"}}} - {"id":"stores:32","replyTo":"localhost:24224/output","dataset":"Starbucks","type":"add","body":{"table":"Store","key":"36th and Madison - New York NY (W)","values":{"location":"40.748917,-73.982683"}}} - {"id":"stores:33","replyTo":"localhost:24224/output","dataset":"Starbucks","type":"add","body":{"table":"Store","key":"125th St. btwn Adam Clayton & FDB - New York NY","values":{"location":"40.808952,-73.948229"}}} - {"id":"stores:34","replyTo":"localhost:24224/output","dataset":"Starbucks","type":"add","body":{"table":"Store","key":"70th & Broadway - New York NY (W)","values":{"location":"40.777463,-73.982237"}}} - {"id":"stores:35","replyTo":"localhost:24224/output","dataset":"Starbucks","type":"add","body":{"table":"Store","key":"2138 Broadway - New York NY (W)","values":{"location":"40.781078,-73.981167"}}} - {"id":"stores:36","replyTo":"localhost:24224/output","dataset":"Starbucks","type":"add","body":{"table":"Store","key":"118th & Frederick Douglas Blvd. - New York NY (W)","values":{"location":"40.806176,-73.954109"}}} - {"id":"stores:37","replyTo":"localhost:24224/output","dataset":"Starbucks","type":"add","body":{"table":"Store","key":"42nd & Second - New York NY (W)","values":{"location":"40.750069,-73.973393"}}} - {"id":"stores:38","replyTo":"localhost:24224/output","dataset":"Starbucks","type":"add","body":{"table":"Store","key":"Broadway @ 81st - New York NY (W)","values":{"location":"40.784972,-73.978987"}}} - {"id":"stores:39","replyTo":"localhost:24224/output","dataset":"Starbucks","type":"add","body":{"table":"Store","key":"Fashion Inst of Technology - New York NY","values":{"location":"40.746948,-73.994557"}}} - - -Open another terminal and send those two jsons `ddl.jsons` and `stores.jsons` to the fluentd server: - - # fluent-cat starbucks.message < ddl.jsons - # fluent-cat starbucks.message < stores.jsons - - -これで、スターバックスの店舗のデータベースを検索するための Droonga Engine ができました。 -引き続き Protocol Adapter を構築して、検索リクエストを受け付けられるようにしましょう。 +~~~ +{"dataset":"Starbucks","type":"add","body":{"table":"Store","key":"1st Avenue & 75th St. - New York NY (W)","values":{"location":"40.770262,-73.954798"}}} +{"dataset":"Starbucks","type":"add","body":{"table":"Store","key":"76th & Second - New York NY (W)","values":{"location":"40.771056,-73.956757"}}} +{"dataset":"Starbucks","type":"add","body":{"table":"Store","key":"2nd Ave. & 9th Street - New York NY","values":{"location":"40.729445,-73.987471"}}} +{"dataset":"Starbucks","type":"add","body":{"table":"Store","key":"15th & Third - New York NY (W)","values":{"location":"40.733946,-73.9867"}}} +{"dataset":"Starbucks","type":"add","body":{"table":"Store","key":"41st and Broadway - New York NY (W)","values":{"location":"40.755111,-73.986225"}}} +{"dataset":"Starbucks","type":"add","body":{"table":"Store","key":"84th & Third Ave - New York NY (W)","values":{"location":"40.777485,-73.954979"}}} +{"dataset":"Starbucks","type":"add","body":{"table":"Store","key":"150 E. 42nd Street - New York NY (W)","values":{"location":"40.750784,-73.975582"}}} +{"dataset":"Starbucks","type":"add","body":{"table":"Store","key":"West 43rd and Broadway - New York NY (W)","values":{"location":"40.756197,-73.985624"}}} +{"dataset":"Starbucks","type":"add","body":{"table":"Store","key":"Macy's 35th Street Balcony - New York NY","values":{"location":"40.750703,-73.989787"}}} +{"dataset":"Starbucks","type":"add","body":{"table":"Store","key":"Macy's 6th Floor - Herald Square - New York NY (W)","values":{"location":"40.750703,-73.989787"}}} +{"dataset":"Starbucks","type":"add","body":{"table":"Store","key":"Herald Square- Macy's - New York NY","values":{"location":"40.750703,-73.989787"}}} +{"dataset":"Starbucks","type":"add","body":{"table":"Store","key":"Macy's 5th Floor - Herald Square - New York NY (W)","values":{"location":"40.750703,-73.989787"}}} +{"dataset":"Starbucks","type":"add","body":{"table":"Store","key":"80th & York - New York NY (W)","values":{"location":"40.772204,-73.949862"}}} +{"dataset":"Starbucks","type":"add","body":{"table":"Store","key":"Columbus @ 67th - New York NY (W)","values":{"location":"40.774009,-73.981472"}}} +{"dataset":"Starbucks","type":"add","body":{"table":"Store","key":"45th & Broadway - New York NY (W)","values":{"location":"40.75766,-73.985719"}}} +{"dataset":"Starbucks","type":"add","body":{"table":"Store","key":"Marriott Marquis - Lobby - New York NY","values":{"location":"40.759123,-73.984927"}}} +{"dataset":"Starbucks","type":"add","body":{"table":"Store","key":"Second @ 81st - New York NY (W)","values":{"location":"40.77466,-73.954447"}}} +{"dataset":"Starbucks","type":"add","body":{"table":"Store","key":"52nd & Seventh - New York NY (W)","values":{"location":"40.761829,-73.981141"}}} +{"dataset":"Starbucks","type":"add","body":{"table":"Store","key":"1585 Broadway (47th) - New York NY (W)","values":{"location":"40.759806,-73.985066"}}} +{"dataset":"Starbucks","type":"add","body":{"table":"Store","key":"85th & First - New York NY (W)","values":{"location":"40.776101,-73.949971"}}} +{"dataset":"Starbucks","type":"add","body":{"table":"Store","key":"92nd & 3rd - New York NY (W)","values":{"location":"40.782606,-73.951235"}}} +{"dataset":"Starbucks","type":"add","body":{"table":"Store","key":"165 Broadway - 1 Liberty - New York NY (W)","values":{"location":"40.709727,-74.011395"}}} +{"dataset":"Starbucks","type":"add","body":{"table":"Store","key":"1656 Broadway - New York NY (W)","values":{"location":"40.762434,-73.983364"}}} +{"dataset":"Starbucks","type":"add","body":{"table":"Store","key":"54th & Broadway - New York NY (W)","values":{"location":"40.764275,-73.982361"}}} +{"dataset":"Starbucks","type":"add","body":{"table":"Store","key":"Limited Brands-NYC - New York NY","values":{"location":"40.765219,-73.982025"}}} +{"dataset":"Starbucks","type":"add","body":{"table":"Store","key":"19th & 8th - New York NY (W)","values":{"location":"40.743218,-74.000605"}}} +{"dataset":"Starbucks","type":"add","body":{"table":"Store","key":"60th & Broadway-II - New York NY (W)","values":{"location":"40.769196,-73.982576"}}} +{"dataset":"Starbucks","type":"add","body":{"table":"Store","key":"63rd & Broadway - New York NY (W)","values":{"location":"40.771376,-73.982709"}}} +{"dataset":"Starbucks","type":"add","body":{"table":"Store","key":"195 Broadway - New York NY (W)","values":{"location":"40.710703,-74.009485"}}} +{"dataset":"Starbucks","type":"add","body":{"table":"Store","key":"2 Broadway - New York NY (W)","values":{"location":"40.704538,-74.01324"}}} +{"dataset":"Starbucks","type":"add","body":{"table":"Store","key":"2 Columbus Ave. - New York NY (W)","values":{"location":"40.769262,-73.984764"}}} +{"dataset":"Starbucks","type":"add","body":{"table":"Store","key":"NY Plaza - New York NY (W)","values":{"location":"40.702802,-74.012784"}}} +{"dataset":"Starbucks","type":"add","body":{"table":"Store","key":"36th and Madison - New York NY (W)","values":{"location":"40.748917,-73.982683"}}} +{"dataset":"Starbucks","type":"add","body":{"table":"Store","key":"125th St. btwn Adam Clayton & FDB - New York NY","values":{"location":"40.808952,-73.948229"}}} +{"dataset":"Starbucks","type":"add","body":{"table":"Store","key":"70th & Broadway - New York NY (W)","values":{"location":"40.777463,-73.982237"}}} +~~~ + +Open another terminal and send those two jsons to the fluentd server. + +Send `ddl.jsons` as follows: + +~~~ +# droonga-request --tag starbucks ddl.jsons +Elapsed time: 0.060984 +[ + "droonga.message", + 1392611486, + { + "inReplyTo": "1392611486.207507", + "statusCode": 200, + "type": "table_create.result", + "body": [ + [ + 0, + 1392611486.2097359, + 0.026822328567504883 + ], + true + ] + } +] +Elapsed time: 0.007164 +[ + "droonga.message", + 1392611486, + { + "inReplyTo": "1392611486.268766", + "statusCode": 200, + "type": "column_create.result", + "body": [ + [ + 0, + 1392611486.269676, + 0.0010280609130859375 + ], + true + ] + } +] +Elapsed time: 0.008584 +[ + "droonga.message", + 1392611486, + { + "inReplyTo": "1392611486.2760692", + "statusCode": 200, + "type": "table_create.result", + "body": [ + [ + 0, + 1392611486.276955, + 0.002329111099243164 + ], + true + ] + } +] +Elapsed time: 0.109383 +[ + "droonga.message", + 1392611486, + { + "inReplyTo": "1392611486.284704", + "statusCode": 200, + "type": "column_create.result", + "body": [ + [ + 0, + 1392611486.2854872, + 0.00432896614074707 + ], + true + ] + } +] +Elapsed time: 0.008829 +[ + "droonga.message", + 1392611486, + { + "inReplyTo": "1392611486.394273", + "statusCode": 200, + "type": "table_create.result", + "body": [ + [ + 0, + 1392611486.395301, + 0.0017240047454833984 + ], + true + ] + } +] +Elapsed time: 0.11633 +[ + "droonga.message", + 1392611486, + { + "inReplyTo": "1392611486.4032152", + "statusCode": 200, + "type": "column_create.result", + "body": [ + [ + 0, + 1392611486.404574, + 0.018894195556640625 + ], + true + ] + } +] +~~~ + +Send `ddl.jsons` as follows: + +~~~ + +$ droonga-request --tag starbucks stores.jsons +Elapsed time: 0.251712 +[ + "droonga.message", + 1392611703, + { + "inReplyTo": "1392611703.414268", + "statusCode": 200, + "type": "add.result", + "body": true + } +] +Elapsed time: 0.007161 +[ + "droonga.message", + 1392611703, + { + "inReplyTo": "1392611703.666198", + "statusCode": 200, + "type": "add.result", + "body": true + } +] +Elapsed time: 0.006794 +[ + "droonga.message", + 1392611703, + { + "inReplyTo": "1392611703.6735082", + "statusCode": 200, + "type": "add.result", + "body": true + } +] +Elapsed time: 0.070859 +[ + "droonga.message", + 1392611703, + { + "inReplyTo": "1392611703.680408", + "statusCode": 200, + "type": "add.result", + "body": true + } +] +Elapsed time: 0.064862 +[ + "droonga.message", + 1392611703, + { + "inReplyTo": "1392611703.7514088", + "statusCode": 200, + "type": "add.result", + "body": true + } +] +Elapsed time: 0.009247 +[ + "droonga.message", + 1392611703, + { + "inReplyTo": "1392611703.816423", + "statusCode": 200, + "type": "add.result", + "body": true + } +] +Elapsed time: 0.012615 +[ + "droonga.message", + 1392611703, + { + "inReplyTo": "1392611703.825906", + "statusCode": 200, + "type": "add.result", + "body": true + } +] +Elapsed time: 0.01329 +[ + "droonga.message", + 1392611703, + { + "inReplyTo": "1392611703.838811", + "statusCode": 200, + "type": "add.result", + "body": true + } +] +Elapsed time: 0.016937 +[ + "droonga.message", + 1392611703, + { + "inReplyTo": "1392611703.852271", + "statusCode": 200, + "type": "add.result", + "body": true + } +] +Elapsed time: 0.009726 +[ + "droonga.message", + 1392611703, + { + "inReplyTo": "1392611703.8693151", + "statusCode": 200, + "type": "add.result", + "body": true + } +] +Elapsed time: 0.009445 +[ + "droonga.message", + 1392611703, + { + "inReplyTo": "1392611703.879232", + "statusCode": 200, + "type": "add.result", + "body": true + } +] +Elapsed time: 0.003686 +[ + "droonga.message", + 1392611703, + { + "inReplyTo": "1392611703.888693", + "statusCode": 200, + "type": "add.result", + "body": true + } +] +Elapsed time: 0.00309 +[ + "droonga.message", + 1392611703, + { + "inReplyTo": "1392611703.892619", + "statusCode": 200, + "type": "add.result", + "body": true + } +] +Elapsed time: 0.007988 +[ + "droonga.message", + 1392611703, + { + "inReplyTo": "1392611703.895704", + "statusCode": 200, + "type": "add.result", + "body": true + } +] +Elapsed time: 0.003158 +[ + "droonga.message", + 1392611703, + { + "inReplyTo": "1392611703.903796", + "statusCode": 200, + "type": "add.result", + "body": true + } +] +Elapsed time: 0.006433 +[ + "droonga.message", + 1392611703, + { + "inReplyTo": "1392611703.907073", + "statusCode": 200, + "type": "add.result", + "body": true + } +] +Elapsed time: 0.006858 +[ + "droonga.message", + 1392611703, + { + "inReplyTo": "1392611703.913633", + "statusCode": 200, + "type": "add.result", + "body": true + } +] +Elapsed time: 0.003178 +[ + "droonga.message", + 1392611703, + { + "inReplyTo": "1392611703.920607", + "statusCode": 200, + "type": "add.result", + "body": true + } +] +Elapsed time: 0.002921 +[ + "droonga.message", + 1392611703, + { + "inReplyTo": "1392611703.923857", + "statusCode": 200, + "type": "add.result", + "body": true + } +] +Elapsed time: 0.002627 +[ + "droonga.message", + 1392611703, + { + "inReplyTo": "1392611703.926882", + "statusCode": 200, + "type": "add.result", + "body": true + } +] +Elapsed time: 0.002955 +[ + "droonga.message", + 1392611703, + { + "inReplyTo": "1392611703.92959", + "statusCode": 200, + "type": "add.result", + "body": true + } +] +Elapsed time: 0.003133 +[ + "droonga.message", + 1392611703, + { + "inReplyTo": "1392611703.932686", + "statusCode": 200, + "type": "add.result", + "body": true + } +] +Elapsed time: 0.002871 +[ + "droonga.message", + 1392611703, + { + "inReplyTo": "1392611703.9359381", + "statusCode": 200, + "type": "add.result", + "body": true + } +] +Elapsed time: 0.00274 +[ + "droonga.message", + 1392611703, + { + "inReplyTo": "1392611703.938964", + "statusCode": 200, + "type": "add.result", + "body": true + } +] +Elapsed time: 0.002905 +[ + "droonga.message", + 1392611703, + { + "inReplyTo": "1392611703.941767", + "statusCode": 200, + "type": "add.result", + "body": true + } +] +Elapsed time: 0.002512 +[ + "droonga.message", + 1392611703, + { + "inReplyTo": "1392611703.94483", + "statusCode": 200, + "type": "add.result", + "body": true + } +] +Elapsed time: 0.002553 +[ + "droonga.message", + 1392611703, + { + "inReplyTo": "1392611703.947414", + "statusCode": 200, + "type": "add.result", + "body": true + } +] +Elapsed time: 0.002482 +[ + "droonga.message", + 1392611703, + { + "inReplyTo": "1392611703.950102", + "statusCode": 200, + "type": "add.result", + "body": true + } +] +Elapsed time: 0.00294 +[ + "droonga.message", + 1392611703, + { + "inReplyTo": "1392611703.952671", + "statusCode": 200, + "type": "add.result", + "body": true + } +] +Elapsed time: 0.003141 +[ + "droonga.message", + 1392611703, + { + "inReplyTo": "1392611703.955711", + "statusCode": 200, + "type": "add.result", + "body": true + } +] +Elapsed time: 0.002479 +[ + "droonga.message", + 1392611703, + { + "inReplyTo": "1392611703.958953", + "statusCode": 200, + "type": "add.result", + "body": true + } +] +Elapsed time: 0.002375 +[ + "droonga.message", + 1392611703, + { + "inReplyTo": "1392611703.9615061", + "statusCode": 200, + "type": "add.result", + "body": true + } +] +Elapsed time: 0.002571 +[ + "droonga.message", + 1392611703, + { + "inReplyTo": "1392611703.963968", + "statusCode": 200, + "type": "add.result", + "body": true + } +] +Elapsed time: 0.003212 +[ + "droonga.message", + 1392611703, + { + "inReplyTo": "1392611703.966677", + "statusCode": 200, + "type": "add.result", + "body": true + } +] +Elapsed time: 0.002769 +[ + "droonga.message", + 1392611703, + { + "inReplyTo": "1392611703.970025", + "statusCode": 200, + "type": "add.result", + "body": true + } +] +~~~ + +Now a Droonga engine for searching Starbucks stores database is ready. + +### Send request with droonga-request + +Check if it is working. Create a query as a JSON file as follows. + +search-all-stores.json: + +~~~ +{ + "dataset": "Starbucks" + "queries": { + "stores": { + "source": "Store", + "output": { + "elements": [ + "startTime", + "elapsedTime", + "count", + "attributes", + "records" + ], + "attributes": ["_key"], + "limit": -1 + } + } + } +} +~~~ + +Droonga Engine にリクエストを送信します: + +~~~ +# droonga-request --tag starbucks search-all-stores.json +Elapsed time: 0.202101 +[ + "droonga.message", + 1392614906, + { + "inReplyTo": "1392614905.993328", + "statusCode": 200, + "type": "search.result", + "body": { + "stores": { + "count": 35, + "records": [ + [ + "1st Avenue & 75th St. - New York NY (W)" + ], + [ + "76th & Second - New York NY (W)" + ], + [ + "2nd Ave. & 9th Street - New York NY" + ], + [ + "84th & Third Ave - New York NY (W)" + ], + [ + "Macy's 35th Street Balcony - New York NY" + ], + [ + "80th & York - New York NY (W)" + ], + [ + "45th & Broadway - New York NY (W)" + ], + [ + "1585 Broadway (47th) - New York NY (W)" + ], + [ + "85th & First - New York NY (W)" + ], + [ + "1656 Broadway - New York NY (W)" + ], + [ + "2 Broadway - New York NY (W)" + ], + [ + "NY Plaza - New York NY (W)" + ], + [ + "70th & Broadway - New York NY (W)" + ], + [ + "15th & Third - New York NY (W)" + ], + [ + "West 43rd and Broadway - New York NY (W)" + ], + [ + "Macy's 6th Floor - Herald Square - New York NY (W)" + ], + [ + "Herald Square- Macy's - New York NY" + ], + [ + "Macy's 5th Floor - Herald Square - New York NY (W)" + ], + [ + "52nd & Seventh - New York NY (W)" + ], + [ + "92nd & 3rd - New York NY (W)" + ], + [ + "Limited Brands-NYC - New York NY" + ], + [ + "19th & 8th - New York NY (W)" + ], + [ + "60th & Broadway-II - New York NY (W)" + ], + [ + "36th and Madison - New York NY (W)" + ], + [ + "125th St. btwn Adam Clayton & FDB - New York NY" + ], + [ + "41st and Broadway - New York NY (W)" + ], + [ + "150 E. 42nd Street - New York NY (W)" + ], + [ + "Columbus @ 67th - New York NY (W)" + ], + [ + "Marriott Marquis - Lobby - New York NY" + ], + [ + "Second @ 81st - New York NY (W)" + ], + [ + "165 Broadway - 1 Liberty - New York NY (W)" + ], + [ + "54th & Broadway - New York NY (W)" + ], + [ + "63rd & Broadway - New York NY (W)" + ], + [ + "195 Broadway - New York NY (W)" + ], + [ + "2 Columbus Ave. - New York NY (W)" + ] + ] + } + } + } +] +~~~ +店舗の名前が取得できました。エンジンは正しく動作しているようです。引き続き Protocol Adapter を構築して、検索リクエストを受け付けられるようにしましょう。 ## Protocol Adapter を構築する Modified: ja/tutorial/plugin-development/adapter/index.md (+178 -58) =================================================================== --- ja/tutorial/plugin-development/adapter/index.md 2014-02-17 16:32:06 +0900 (dc29f18) +++ ja/tutorial/plugin-development/adapter/index.md 2014-02-17 16:36:15 +0900 (e51d66b) @@ -118,23 +118,14 @@ Note that you need to specify `./lib` directory in `RUBYLIB` environment variabl ### Test -In the [basic tutorial][], we have communicated with the Droonga Engine based on `fluent-plugin-droonga`, via the Protocol Adapter built with `expres-droonga`. For plugin development, sending requests directly to the Droonga Engine can be more handy way to debug. -We use `fluent-cat` command for this purpose. - -Doing in this way also help us to understand internal structure of Droonga. - -In the [basic tutorial][], we have used `fluent-cat` to setup database schema and import data. Do you remember? Sending search request can be done in the similar way. - -First, create a request as a JSON. +Check if the engine is working. First, create a request as a JSON. search-columbus.json: ~~~json { - "id" : "search:0", "dataset" : "Starbucks", "type" : "search", - "replyTo" : "localhost:24224/output", "body" : { "queries" : { "stores" : { @@ -162,25 +153,37 @@ search-columbus.json: This is corresponding to the example to search "Columbus" in the [basic tutorial][]. Note that the request for the Protocol Adapter is encapsulated in `"body"` element. -`fluent-cat` expects one line per one JSON object. So we need to use `tr` command to remove line breaks before passing the JSON to `fluent-cat`: - -~~~ -# cat search-columbus.json | tr -d "\n" | fluent-cat starbucks.message -~~~ - -This will output something like below to fluentd's log in `fluentd.log`: - -~~~ -2014-02-03 14:22:54 +0900 output.message: {"inReplyTo":"search:0","statusCode":200,"type":"search.result","body":{"stores":{"count":2,"records":[["2 Columbus Ave. - New York NY (W)"],["Columbus @ 67th - New York NY (W)"]]}}} +Send the request to engine with `droonga-request`: + +~~~ +# droonga-request --tag starbucks search-columbus.json +Elapsed time: 0.021544 +[ + "droonga.message", + 1392617533, + { + "inReplyTo": "1392617533.9644868", + "statusCode": 200, + "type": "search.result", + "body": { + "stores": { + "count": 2, + "records": [ + [ + "Columbus @ 67th - New York NY (W)" + ], + [ + "2 Columbus Ave. - New York NY (W)" + ] + ] + } + } + } +] ~~~ This is the search result. -If you have [jq][] installed, you can use `jq` instead of `tr`: - -~~~ -# jq -c . search-columbus.json | fluent-cat starbucks.message -~~~ ### Do something in the plugin: take logs @@ -213,17 +216,39 @@ Restart fluentd: # RUBYLIB=./lib fluentd --config fluentd.conf --log fluentd.log --daemon fluentd.pid ~~~ -Send the request same as the previous: - -~~~ -# cat search-columbus.json | tr -d "\n" | fluent-cat starbucks.message +Send the request same as the previous section: + +~~~ +# droonga-request --tag starbucks search-columbus.json +Elapsed time: 0.014714 +[ + "droonga.message", + 1392618037, + { + "inReplyTo": "1392618037.935901", + "statusCode": 200, + "type": "search.result", + "body": { + "stores": { + "count": 2, + "records": [ + [ + "Columbus @ 67th - New York NY (W)" + ], + [ + "2 Columbus Ave. - New York NY (W)" + ] + ] + } + } + } +] ~~~ You will see something like below fluentd's log in `fluentd.log`: ~~~ -2014-02-03 16:56:27 +0900 [info]: SampleLoggerPlugin::Adapter message=#<Droonga::InputMessage:0x007ff36a38cb28 @raw_message={"body"=>{"queries"=>{"stores"=>{"output"=>{"limit"=>-1, "attributes"=>["_key"], "elements"=>["startTime", "elapsedTime", "count", "attributes", "records"]}, "condition"=>{"matchTo"=>"_key", "query"=>"Columbus"}, "source"=>"Store"}}}, "replyTo"=>{"type"=>"search.result", "to"=>"localhost:24224/output"}, "type"=>"search", "dataset"=>"Starbucks", "id"=>"search"}> -2014-02-03 16:56:27 +0900 output.message: {"inReplyTo":"search","statusCode":200,"type":"search.result","body":{"stores":{"count":2,"records":[["2 Columbus Ave. - New York NY (W)"],["Columbus @ 67th - New York NY (W)"]]}}} +2014-02-17 15:20:37 +0900 [info]: SampleLoggerPlugin::Adapter message=#<Droonga::InputMessage:0x007f8ae3e1dd98 @raw_message={"dataset"=>"Starbucks", "type"=>"search", "body"=>{"queries"=>{"stores"=>{"source"=>"Store", "condition"=>{"query"=>"Columbus", "matchTo"=>"_key"}, "output"=>{"elements"=>["startTime", "elapsedTime", "count", "attributes", "records"], "attributes"=>["_key"], "limit"=>-1}}}}, "replyTo"=>{"type"=>"search.result", "to"=>"127.0.0.1:64591/droonga"}, "id"=>"1392618037.935901", "date"=>"2014-02-17 15:20:37 +0900", "appliedAdapters"=>[]}> ~~~ This shows the message is received by our `SampleLoggerPlugin::Adapter` and then passed to Droonga. Here we can modify the message before the actual data processing. @@ -255,19 +280,37 @@ After restart, the response always includes only one record in `records` section Send the request same as the previous: ~~~ -# cat search-columbus.json | tr -d "\n" | fluent-cat starbucks.message +$ droonga-request --tag starbucks search-columbus.json +Elapsed time: 0.017343 +[ + "droonga.message", + 1392618279, + { + "inReplyTo": "1392618279.0578449", + "statusCode": 200, + "type": "search.result", + "body": { + "stores": { + "count": 2, + "records": [ + [ + "Columbus @ 67th - New York NY (W)" + ] + ] + } + } + } +] ~~~ +Note that `count` is still `2` because `limit` does not affect to `count`. See [search][] for details of the `search` command. + You will see something like below fluentd's log in `fluentd.log`: ~~~ -2014-02-03 18:47:54 +0900 [info]: SampleLoggerPlugin::Adapter message=#<Droonga::InputMessage:0x007f913ca6e918 @raw_message={"body"=>{"queries"=>{"stores"=>{"output"=>{"limit"=>-1, "attributes"=>["_key"], "elements"=>["startTime", "elapsedTime", "count", "attributes", "records"]}, "condition"=>{"matchTo"=>"_key", "query"=>"Columbus"}, "source"=>"Store"}}}, "replyTo"=>{"type"=>"search.result", "to"=>"localhost:24224/output"}, "type"=>"search", "dataset"=>"Starbucks", "id"=>"search"}> -2014-02-03 18:47:54 +0900 output.message: {"inReplyTo":"search","statusCode":200,"type":"search.result","body":{"stores":{"count":2,"records":[["2 Columbus Ave. - New York NY (W)"]]}}} +2014-02-17 15:24:39 +0900 [info]: SampleLoggerPlugin::Adapter message=#<Droonga::InputMessage:0x007f956685c908 @raw_message={"dataset"=>"Starbucks", "type"=>"search", "body"=>{"queries"=>{"stores"=>{"source"=>"Store", "condition"=>{"query"=>"Columbus", "matchTo"=>"_key"}, "output"=>{"elements"=>["startTime", "elapsedTime", "count", "attributes", "records"], "attributes"=>["_key"], "limit"=>-1}}}}, "replyTo"=>{"type"=>"search.result", "to"=>"127.0.0.1:64616/droonga"}, "id"=>"1392618279.0578449", "date"=>"2014-02-17 15:24:39 +0900", "appliedAdapters"=>[]}> ~~~ -Note that `count` is still `2` because `limit` does not affect to `count`. See [search][] for details of the `search` command. - - ## Adaption for outgoing messages @@ -278,7 +321,8 @@ In this section, we are going to define a method to adapt outgoing messages. ### Add a method to adapt outgoing messages Let's take logs of results of `search` command. -Define the `adapt_output` method to process outgoing messages, like below: +Define the `adapt_output` method to process outgoing messages. +Remove `adapt_input` at this moment for the simplicity. lib/droonga/plugins/sample-logger.rb: @@ -288,8 +332,6 @@ lib/droonga/plugins/sample-logger.rb: Plugin.registry.register("sample-logger", self) class Adapter < Droonga::Adapter - (snip) - def adapt_output(output_message) $log.info("SampleLoggerPlugin::Adapter", :message => output_message) end @@ -310,14 +352,36 @@ Let's restart fluentd: And send search request (Use the same JSON for request as in the previous section): ~~~ -# cat search-columbus.json | tr -d "\n" | fluent-cat starbucks.message +$ droonga-request --tag starbucks search-columbus.json +Elapsed time: 0.015491 +[ + "droonga.message", + 1392619269, + { + "inReplyTo": "1392619269.184789", + "statusCode": 200, + "type": "search.result", + "body": { + "stores": { + "count": 2, + "records": [ + [ + "Columbus @ 67th - New York NY (W)" + ], + [ + "2 Columbus Ave. - New York NY (W)" + ] + ] + } + } + } +] ~~~ The fluentd's log should be like as follows: ~~~ -2014-02-05 17:37:37 +0900 [info]: SampleLoggerPlugin::Adapter message=#<Droonga::OutputMessage:0x007f8da265b698 @raw_message={"body"=>{"stores"=>{"count"=>2, "records"=>[["2 Columbus Ave. - New York NY (W)"], ["Columbus @ 67th - New York NY (W)"]]}}, "replyTo"=>{"type"=>"search.result", "to"=>"localhost:24224/output"}, "type"=>"search", "dataset"=>"Starbucks", "id"=>"search"}> -2014-02-05 17:37:37 +0900 output.message: {"inReplyTo":"search","statusCode":200,"type":"search.result","body":{"stores":{"count":2,"records":[["2 Columbus Ave. - New York NY (W)"],["Columbus @ 67th - New York NY (W)"]]}}} +2014-02-17 15:41:09 +0900 [info]: SampleLoggerPlugin::Adapter message=#<Droonga::OutputMessage:0x007fddcad4d5a0 @raw_message={"dataset"=>"Starbucks", "type"=>"dispatcher", "body"=>{"stores"=>{"count"=>2, "records"=>[["Columbus @ 67th - New York NY (W)"], ["2 Columbus Ave. - New York NY (W)"]]}}, "replyTo"=>{"type"=>"search.result", "to"=>"127.0.0.1:64724/droonga"}, "id"=>"1392619269.184789", "date"=>"2014-02-17 15:41:09 +0900", "appliedAdapters"=>["Droonga::Plugins::SampleLoggerPlugin::Adapter", "Droonga::Plugins::Error::Adapter"]}> ~~~ This shows that the result of `search` is passed to the `adapt_output` method (and logged), then outputted. @@ -350,17 +414,40 @@ Restart fluentd: Send the same search request: ~~~ -# cat search-columbus.json | tr -d "\n" | fluent-cat starbucks.message +# droonga-request --tag starbucks search-columbus.json +Elapsed time: 0.013983 +[ + "droonga.message", + 1392619528, + { + "inReplyTo": "1392619528.235121", + "statusCode": 200, + "type": "search.result", + "body": { + "stores": { + "count": 2, + "records": [ + [ + "Columbus @ 67th - New York NY (W)" + ], + [ + "2 Columbus Ave. - New York NY (W)" + ] + ], + "completedAt": "2014-02-17T06:45:28.247669Z" + } + } + } +] ~~~ +Now you can see `completedAt` attribute containing the time completed the request. The results in `fluentd.log` will be like this: ~~~ -2014-02-05 17:41:02 +0900 [info]: SampleLoggerPlugin::Adapter message=#<Droonga::OutputMessage:0x007fb3c5291fc8 @raw_message={"body"=>{"stores"=>{"count"=>2, "records"=>[["2 Columbus Ave. - New York NY (W)"], ["Columbus @ 67th - New York NY (W)"]]}}, "replyTo"=>{"type"=>"search.result", "to"=>"localhost:24224/output"}, "type"=>"search", "dataset"=>"Starbucks", "id"=>"search"}> -2014-02-05 17:41:02 +0900 output.message: {"inReplyTo":"search","statusCode":200,"type":"search.result","body":{"stores":{"count":2,"records":[["2 Columbus Ave. - New York NY (W)"],["Columbus @ 67th - New York NY (W)"]],"completedAt":"2014-02-05T08:41:02.824361Z"}}} +2014-02-17 15:45:28 +0900 [info]: SampleLoggerPlugin::Adapter message=#<Droonga::OutputMessage:0x007fd384f3ab60 @raw_message={"dataset"=>"Starbucks", "type"=>"dispatcher", "body"=>{"stores"=>{"count"=>2, "records"=>[["Columbus @ 67th - New York NY (W)"], ["2 Columbus Ave. - New York NY (W)"]]}}, "replyTo"=>{"type"=>"search.result", "to"=>"127.0.0.1:64849/droonga"}, "id"=>"1392619528.235121", "date"=>"2014-02-17 15:45:28 +0900", "appliedAdapters"=>["Droonga::Plugins::SampleLoggerPlugin::Adapter", "Droonga::Plugins::Error::Adapter"]}> ~~~ -Now you can see `completedAt` attribute containing the time completed the request. ## Translation for both incoming and outgoing messages @@ -455,10 +542,8 @@ store-search-columbus.json: ~~~json { - "id" : "storeSearch:0", "dataset" : "Starbucks", "type" : "storeSearch", - "replyTo" : "localhost:24224/output", "body" : { "query" : "Columbus" } @@ -468,15 +553,37 @@ store-search-columbus.json: In order to issue this request, you need to run: ~~~ -# cat store-search-columbus.json | tr -d "\n" | fluent-cat starbucks.message +# droonga-request --tag starbucks store-search-columbus.json +Elapsed time: 0.01494 +[ + "droonga.message", + 1392621168, + { + "inReplyTo": "1392621168.0119512", + "statusCode": 200, + "type": "storeSearch.result", + "body": { + "stores": { + "count": 2, + "records": [ + [ + "Columbus @ 67th - New York NY (W)" + ], + [ + "2 Columbus Ave. - New York NY (W)" + ] + ] + } + } + } +] ~~~ And you will see the result on fluentd's log in `fluentd.log`: ~~~ -2014-02-06 15:20:07 +0900 [info]: StoreSearchPlugin::Adapter message=#<Droonga::InputMessage:0x00000002a0de38 @raw_message={"id"=>"storeSearch:0", "dataset"=>"Starbucks", "type"=>"storeSearch", "replyTo"=>{"type"=>"storeSearch.result", "to"=>"localhost:24224/output"}, "body"=>{"query"=>"Columbus"}, "appliedAdapters"=>[]}> -2014-02-06 15:20:07 +0900 [info]: storeSearch query="Columbus" -2014-02-06 15:20:07 +0900 output.message: {"inReplyTo":"storeSearch:0","statusCode":200,"type":"storeSearch.result","body":{"stores":{"count":2,"records":[["2 Columbus Ave. - New York NY (W)"],["Columbus @ 67th - New York NY (W)"]]}}} +2014-02-17 16:12:48 +0900 [info]: StoreSearchPlugin::Adapter message=#<Droonga::InputMessage:0x007fe4791d3958 @raw_message={"dataset"=>"Starbucks", "type"=>"storeSearch", "body"=>{"query"=>"Columbus"}, "replyTo"=>{"type"=>"storeSearch.result", "to"=>"127.0.0.1:49934/droonga"}, "id"=>"1392621168.0119512", "date"=>"2014-02-17 16:12:48 +0900", "appliedAdapters"=>[]}> +2014-02-17 16:12:48 +0900 [info]: storeSearch query="Columbus" ~~~ Now we can perform store search with simple requests. @@ -524,16 +631,29 @@ Restart fluentd: Send the request: ~~~ -# cat store-search-columbus.json | tr -d "\n" | fluent-cat starbucks.message +# droonga-request --tag starbucks store-search-columbus.json +Elapsed time: 0.014859 +[ + "droonga.message", + 1392621288, + { + "inReplyTo": "1392621288.158763", + "statusCode": 200, + "type": "storeSearch.result", + "body": [ + "Columbus @ 67th - New York NY (W)", + "2 Columbus Ave. - New York NY (W)" + ] + } +] ~~~ The log in `fluentd.log` will be like this: ~~~ -2014-02-06 16:04:45 +0900 [info]: StoreSearchPlugin::Adapter message=#<Droonga::InputMessage:0x00000002a0de38 @raw_message={"id"=>"storeSearch:0", "dataset"=>"Starbucks", "type"=>"storeSearch", "replyTo"=>{"type"=>"storeSearch.result", "to"=>"localhost:24224/output"}, "body"=>{"query"=>"Columbus"}, "appliedAdapters"=>[]}> -2014-02-06 16:04:45 +0900 [info]: storeSearch query="Columbus" -2014-02-06 16:04:45 +0900 [info]: StoreSearchPlugin::Adapter message=#<Droonga::OutputMessage:0x00000002a34a88 @raw_message={"id"=>"storeSearch:0", "dataset"=>"Starbucks", "type"=>"search", "replyTo"=>{"type"=>"storeSearch.result", "to"=>"localhost:24224/output"}, "body"=>{"stores"=>{"count"=>2, "records"=>[["2 Columbus Ave. - New York NY (W)"], ["Columbus @ 67th - New York NY (W)"]]}}, "appliedAdapters"=>["Droonga::Plugins::StoreSearchPlugin::Adapter", "Droonga::Plugins::Error::Adapter"], "originalTypes"=>["storeSearch"]}> -2014-02-06 16:04:45 +0900 output.message: {"inReplyTo":"storeSearch:0","statusCode":200,"type":"storeSearch.result","body":["2 Columbus Ave. - New York NY (W)","Columbus @ 67th - New York NY (W)"]} +2014-02-17 16:14:48 +0900 [info]: StoreSearchPlugin::Adapter message=#<Droonga::InputMessage:0x007ffb8ada9d68 @raw_message={"dataset"=>"Starbucks", "type"=>"storeSearch", "body"=>{"query"=>"Columbus"}, "replyTo"=>{"type"=>"storeSearch.result", "to"=>"127.0.0.1:49960/droonga"}, "id"=>"1392621288.158763", "date"=>"2014-02-17 16:14:48 +0900", "appliedAdapters"=>[]}> +2014-02-17 16:14:48 +0900 [info]: storeSearch query="Columbus" +2014-02-17 16:14:48 +0900 [info]: StoreSearchPlugin::Adapter message=#<Droonga::OutputMessage:0x007ffb8ad78e48 @raw_message={"dataset"=>"Starbucks", "type"=>"dispatcher", "body"=>{"stores"=>{"count"=>2, "records"=>[["Columbus @ 67th - New York NY (W)"], ["2 Columbus Ave. - New York NY (W)"]]}}, "replyTo"=>{"type"=>"storeSearch.result", "to"=>"127.0.0.1:49960/droonga"}, "id"=>"1392621288.158763", "date"=>"2014-02-17 16:14:48 +0900", "appliedAdapters"=>["Droonga::Plugins::StoreSearchPlugin::Adapter", "Droonga::Plugins::Error::Adapter"], "originalTypes"=>["storeSearch"]}> ~~~ Now you've got the simplified response. Added: ja/tutorial/plugin-development/handler/index.md (+201 -0) 100644 =================================================================== --- /dev/null +++ ja/tutorial/plugin-development/handler/index.md 2014-02-17 16:36:15 +0900 (43e7312) @@ -0,0 +1,201 @@ +--- +title: "Plugin: Handle requests" +layout: en +--- + +{% comment %} +############################################## + THIS FILE IS AUTOMATICALLY GENERATED FROM + "_po/ja/tutorial/plugin-development/handler/index.po" + DO NOT EDIT THIS FILE MANUALLY! +############################################## +{% endcomment %} + + +!!! WORK IN PROGRESS !!! + +* TOC +{:toc} + +## チュートリアルのゴール + +This tutorial aims to help you to learn how to develop plugins +which extends operations in handle phrase. + +## 前提条件 + +* You must complete [Modify requests and responses tutorial][adapter]. + +## Handling phase + +The handling phase is the phase that the actual storage access is happen. +As Droonga is a distributed system, handler phase is done in multiple partitions. + +Here, in this tutorial, we are going to replace the handling phase of `search` command for explanation. This breaks the `search` command. So this is not useful in practice, but it will help you to learn how Droonga works. + +In practice, we need to *extend* Droonga. In this case, we need to add a new command which does not conflict with the existing commands. To do so, you need to learn not only how to handle messages but also how to distribute messages to handlers and collect messages from them. Proceed to [Distribute requests and collect responses][] after this tutorial completed. + +TODO fix the link to "Distribute requests and collect responses" tutorial + +## Directory Structure + +The directory structure for plugins are in same rule as explained in [Modify requests and responses tutorial][adapter]. + +Now let's create `sample-logger` plugin again. This will act almost same as [Modify requests and responses tutorial][adapter] version, except the phase in which the plugin works. We need to put `sample-logger.rb` to `lib/droonga/plugins/sample-logger.rb`. The directory tree will be like this: + +~~~ +lib +└── droonga + └── plugins + └── sample-logger.rb +~~~ + +## Create a plugin + +Create a plugin as follows: + +lib/droonga/plugins/sample-logger.rb: + +~~~ruby +require "droonga/plugin" + +module Droonga + module Plugins + module SampleLoggerPlugin + Plugin.registry.register("sample-logger", self) + + class Handler < Droonga::Handler + message.type = "search" + + def handle(message, messenger) + $log.info "Droonga::Plugins::SampleLoggerPlugin", :message => message + end + end + end + end +end +~~~ + +## Activate the plugin with `catalog.json` + +Update catalog.json to activate this plugin. Add `"sample-logger"` to `"plugins"`. + +~~~ +(snip) + "datasets": { + "Starbucks": { + (snip) + "plugins": ["sample-logger", "groonga", "crud", "search"], +(snip) +~~~ + +## Run + +Let's get Droonga started. Note that you need to specify ./lib directory in RUBYLIB environment variable in order to make ruby possible to find your plugin. + + # kill $(cat fluentd.pid) + # RUBYLIB=./lib fluentd --config fluentd.conf --log fluentd.log --daemon fluentd.pid + +## Test + +Send a search request to Droonga Engine. Use `search-columbus.json` same as of [Modify requests and responses tutorial][adapter]. + +~~~ +# droonga-request --tag starbucks search-columbus.json +~~~ + +You will see no output for `droonga-request` execution because out `sample-logger` plugin traps the `add` request. + +Instead, you will see something like these lines in `fluentd.log`: + +~~~ +2014-02-17 16:25:23 +0900 [info]: Droonga::Plugins::SampleLoggerPlugin message=#<Droonga::HandlerMessage:0x007f9a7f0987a8 @raw={"dataset"=>"Starbucks", "type"=>"search", "body"=>{"id"=>"localhost:24224/starbucks.#0", "task"=>{"route"=>"localhost:24224/starbucks.011", "step"=>{"command"=>"search", "dataset"=>"Starbucks", "body"=>{"queries"=>{"stores"=>{"source"=>"Store", "condition"=>{"query"=>"Columbus", "matchTo"=>"_key"}, "output"=>{"elements"=>["startTime", "elapsedTime", "count", "attributes", "records"], "attributes"=>["_key"], "limit"=>-1}}}}, "type"=>"broadcast", "outputs"=>["errors", "stores"], "replica"=>"random", "routes"=>["localhost:24224/starbucks.001", "localhost:24224/starbucks.011", "localhost:24224/starbucks.020"], "n_of_expects"=>0, "descendants"=>{"errors"=>["localhost:24224/starbucks.#0"], "stores"=>["localhost:24224/starbucks.#0"]}}, "n_of_inputs"=>0, "values"=>{}}, "descendants"=>{"errors"=>["localhost:24224/starbucks"], "stores"=>["localhost:24224/star bucks"]} }, "replyTo"=>{"type"=>"search.result", "to"=>"127.0.0.1:50410/droonga"}, "id"=>"1392621923.903868", "date"=>"2014-02-17 16:25:23 +0900", "appliedAdapters"=>["Droonga::Plugins::Error::Adapter"]}, @body={"id"=>"localhost:24224/starbucks.#0", "task"=>{"route"=>"localhost:24224/starbucks.011", "step"=>{"command"=>"search", "dataset"=>"Starbucks", "body"=>{"queries"=>{"stores"=>{"source"=>"Store", "condition"=>{"query"=>"Columbus", "matchTo"=>"_key"}, "output"=>{"elements"=>["startTime", "elapsedTime", "count", "attributes", "records"], "attributes"=>["_key"], "limit"=>-1}}}}, "type"=>"broadcast", "outputs"=>["errors", "stores"], "replica"=>"random", "routes"=>["localhost:24224/starbucks.001", "localhost:24224/starbucks.011", "localhost:24224/starbucks.020"], "n_of_expects"=>0, "descendants"=>{"errors"=>["localhost:24224/starbucks.#0"], "stores"=>["localhost:24224/starbucks.#0"]}}, "n_of_inputs"=>0, "values"=>{}}, "descendants"=>{"errors"=>["localhost:24224/starbucks"], "stores" =>["loca lhost:24224/starbucks"]}}, @task={"route"=>"localhost:24224/starbucks.011", "step"=>{"command"=>"search", "dataset"=>"Starbucks", "body"=>{"queries"=>{"stores"=>{"source"=>"Store", "condition"=>{"query"=>"Columbus", "matchTo"=>"_key"}, "output"=>{"elements"=>["startTime", "elapsedTime", "count", "attributes", "records"], "attributes"=>["_key"], "limit"=>-1}}}}, "type"=>"broadcast", "outputs"=>["errors", "stores"], "replica"=>"random", "routes"=>["localhost:24224/starbucks.001", "localhost:24224/starbucks.011", "localhost:24224/starbucks.020"], "n_of_expects"=>0, "descendants"=>{"errors"=>["localhost:24224/starbucks.#0"], "stores"=>["localhost:24224/starbucks.#0"]}}, "n_of_inputs"=>0, "values"=>{}}, @step={"command"=>"search", "dataset"=>"Starbucks", "body"=>{"queries"=>{"stores"=>{"source"=>"Store", "condition"=>{"query"=>"Columbus", "matchTo"=>"_key"}, "output"=>{"elements"=>["startTime", "elapsedTime", "count", "attributes", "records"], "attributes"=>["_key"], "limit"=>-1} }}}, "ty pe"=>"broadcast", "outputs"=>["errors", "stores"], "replica"=>"random", "routes"=>["localhost:24224/starbucks.001", "localhost:24224/starbucks.011", "localhost:24224/starbucks.020"], "n_of_expects"=>0, "descendants"=>{"errors"=>["localhost:24224/starbucks.#0"], "stores"=>["localhost:24224/starbucks.#0"]}}> +2014-02-17 16:25:23 +0900 [info]: Droonga::Plugins::SampleLoggerPlugin message=#<Droonga::HandlerMessage:0x007f9a7f060970 @raw={"dataset"=>"Starbucks", "type"=>"search", "body"=>{"id"=>"localhost:24224/starbucks.#0", "task"=>{"route"=>"localhost:24224/starbucks.020", "step"=>{"command"=>"search", "dataset"=>"Starbucks", "body"=>{"queries"=>{"stores"=>{"source"=>"Store", "condition"=>{"query"=>"Columbus", "matchTo"=>"_key"}, "output"=>{"elements"=>["startTime", "elapsedTime", "count", "attributes", "records"], "attributes"=>["_key"], "limit"=>-1}}}}, "type"=>"broadcast", "outputs"=>["errors", "stores"], "replica"=>"random", "routes"=>["localhost:24224/starbucks.001", "localhost:24224/starbucks.011", "localhost:24224/starbucks.020"], "n_of_expects"=>0, "descendants"=>{"errors"=>["localhost:24224/starbucks.#0"], "stores"=>["localhost:24224/starbucks.#0"]}}, "n_of_inputs"=>0, "values"=>{}}, "descendants"=>{"errors"=>["localhost:24224/starbucks"], "stores"=>["localhost:24224/star bucks"]} }, "replyTo"=>{"type"=>"search.result", "to"=>"127.0.0.1:50410/droonga"}, "id"=>"1392621923.903868", "date"=>"2014-02-17 16:25:23 +0900", "appliedAdapters"=>["Droonga::Plugins::Error::Adapter"]}, @body={"id"=>"localhost:24224/starbucks.#0", "task"=>{"route"=>"localhost:24224/starbucks.020", "step"=>{"command"=>"search", "dataset"=>"Starbucks", "body"=>{"queries"=>{"stores"=>{"source"=>"Store", "condition"=>{"query"=>"Columbus", "matchTo"=>"_key"}, "output"=>{"elements"=>["startTime", "elapsedTime", "count", "attributes", "records"], "attributes"=>["_key"], "limit"=>-1}}}}, "type"=>"broadcast", "outputs"=>["errors", "stores"], "replica"=>"random", "routes"=>["localhost:24224/starbucks.001", "localhost:24224/starbucks.011", "localhost:24224/starbucks.020"], "n_of_expects"=>0, "descendants"=>{"errors"=>["localhost:24224/starbucks.#0"], "stores"=>["localhost:24224/starbucks.#0"]}}, "n_of_inputs"=>0, "values"=>{}}, "descendants"=>{"errors"=>["localhost:24224/starbucks"], "stores" =>["loca lhost:24224/starbucks"]}}, @task={"route"=>"localhost:24224/starbucks.020", "step"=>{"command"=>"search", "dataset"=>"Starbucks", "body"=>{"queries"=>{"stores"=>{"source"=>"Store", "condition"=>{"query"=>"Columbus", "matchTo"=>"_key"}, "output"=>{"elements"=>["startTime", "elapsedTime", "count", "attributes", "records"], "attributes"=>["_key"], "limit"=>-1}}}}, "type"=>"broadcast", "outputs"=>["errors", "stores"], "replica"=>"random", "routes"=>["localhost:24224/starbucks.001", "localhost:24224/starbucks.011", "localhost:24224/starbucks.020"], "n_of_expects"=>0, "descendants"=>{"errors"=>["localhost:24224/starbucks.#0"], "stores"=>["localhost:24224/starbucks.#0"]}}, "n_of_inputs"=>0, "values"=>{}}, @step={"command"=>"search", "dataset"=>"Starbucks", "body"=>{"queries"=>{"stores"=>{"source"=>"Store", "condition"=>{"query"=>"Columbus", "matchTo"=>"_key"}, "output"=>{"elements"=>["startTime", "elapsedTime", "count", "attributes", "records"], "attributes"=>["_key"], "limit"=>-1} }}}, "ty pe"=>"broadcast", "outputs"=>["errors", "stores"], "replica"=>"random", "routes"=>["localhost:24224/starbucks.001", "localhost:24224/starbucks.011", "localhost:24224/starbucks.020"], "n_of_expects"=>0, "descendants"=>{"errors"=>["localhost:24224/starbucks.#0"], "stores"=>["localhost:24224/starbucks.#0"]}}> +2014-02-17 16:25:23 +0900 [info]: Droonga::Plugins::SampleLoggerPlugin message=#<Droonga::HandlerMessage:0x007f9a7f069c50 @raw={"dataset"=>"Starbucks", "type"=>"search", "body"=>{"id"=>"localhost:24224/starbucks.#0", "task"=>{"route"=>"localhost:24224/starbucks.001", "step"=>{"command"=>"search", "dataset"=>"Starbucks", "body"=>{"queries"=>{"stores"=>{"source"=>"Store", "condition"=>{"query"=>"Columbus", "matchTo"=>"_key"}, "output"=>{"elements"=>["startTime", "elapsedTime", "count", "attributes", "records"], "attributes"=>["_key"], "limit"=>-1}}}}, "type"=>"broadcast", "outputs"=>["errors", "stores"], "replica"=>"random", "routes"=>["localhost:24224/starbucks.001", "localhost:24224/starbucks.011", "localhost:24224/starbucks.020"], "n_of_expects"=>0, "descendants"=>{"errors"=>["localhost:24224/starbucks.#0"], "stores"=>["localhost:24224/starbucks.#0"]}}, "n_of_inputs"=>0, "values"=>{}}, "descendants"=>{"errors"=>["localhost:24224/starbucks"], "stores"=>["localhost:24224/star bucks"]} }, "replyTo"=>{"type"=>"search.result", "to"=>"127.0.0.1:50410/droonga"}, "id"=>"1392621923.903868", "date"=>"2014-02-17 16:25:23 +0900", "appliedAdapters"=>["Droonga::Plugins::Error::Adapter"]}, @body={"id"=>"localhost:24224/starbucks.#0", "task"=>{"route"=>"localhost:24224/starbucks.001", "step"=>{"command"=>"search", "dataset"=>"Starbucks", "body"=>{"queries"=>{"stores"=>{"source"=>"Store", "condition"=>{"query"=>"Columbus", "matchTo"=>"_key"}, "output"=>{"elements"=>["startTime", "elapsedTime", "count", "attributes", "records"], "attributes"=>["_key"], "limit"=>-1}}}}, "type"=>"broadcast", "outputs"=>["errors", "stores"], "replica"=>"random", "routes"=>["localhost:24224/starbucks.001", "localhost:24224/starbucks.011", "localhost:24224/starbucks.020"], "n_of_expects"=>0, "descendants"=>{"errors"=>["localhost:24224/starbucks.#0"], "stores"=>["localhost:24224/starbucks.#0"]}}, "n_of_inputs"=>0, "values"=>{}}, "descendants"=>{"errors"=>["localhost:24224/starbucks"], "stores" =>["loca lhost:24224/starbucks"]}}, @task={"route"=>"localhost:24224/starbucks.001", "step"=>{"command"=>"search", "dataset"=>"Starbucks", "body"=>{"queries"=>{"stores"=>{"source"=>"Store", "condition"=>{"query"=>"Columbus", "matchTo"=>"_key"}, "output"=>{"elements"=>["startTime", "elapsedTime", "count", "attributes", "records"], "attributes"=>["_key"], "limit"=>-1}}}}, "type"=>"broadcast", "outputs"=>["errors", "stores"], "replica"=>"random", "routes"=>["localhost:24224/starbucks.001", "localhost:24224/starbucks.011", "localhost:24224/starbucks.020"], "n_of_expects"=>0, "descendants"=>{"errors"=>["localhost:24224/starbucks.#0"], "stores"=>["localhost:24224/starbucks.#0"]}}, "n_of_inputs"=>0, "values"=>{}}, @step={"command"=>"search", "dataset"=>"Starbucks", "body"=>{"queries"=>{"stores"=>{"source"=>"Store", "condition"=>{"query"=>"Columbus", "matchTo"=>"_key"}, "output"=>{"elements"=>["startTime", "elapsedTime", "count", "attributes", "records"], "attributes"=>["_key"], "limit"=>-1} }}}, "ty pe"=>"broadcast", "outputs"=>["errors", "stores"], "replica"=>"random", "routes"=>["localhost:24224/starbucks.001", "localhost:24224/starbucks.011", "localhost:24224/starbucks.020"], "n_of_expects"=>0, "descendants"=>{"errors"=>["localhost:24224/starbucks.#0"], "stores"=>["localhost:24224/starbucks.#0"]}}> +~~~ + +Note that three lines are shown for only one request. What is happening? + +Remember that we have configured `Starbucks` dataset to use three partitions (and each has two replicas) in `catalog.json` of [the basic tutorial][basic]. + +The `search` request is dispatched to three partitions and passed into handling phase for each partition. That is because we saw three lines for one request. + +The messages shown is in internal format, which is transformed from the request you've sent. +You can see your search request is distributed to partitions `localhost:24224/starbucks.000`, `localhost:24224/starbucks.010` and `localhost:24224/starbucks.021` from `"routes"`. + +In `search` case, it is enough to use one replica per one partition because replicas for a partition are expected to have the exactly same contents. +So the planner ordered distributor to choose one replica randomly. + +## Trap "add" command + +We have seen how distributed search is done from the view point of handling phase so far. +How about `"add"` command? + +Update `smaple-logger` plugin to trap `"add"` message instead of `"search"`. + +lib/droonga/plugins/sample-logger.rb: + +~~~ +require "droonga/plugin" + +module Droonga + module Plugins + module SampleLoggerPlugin + Plugin.registry.register("sample-logger", self) + + class Handler < Droonga::Handler + message.type = "add" # This was "search" in the previous version. + + def handle(message, messenger) + $log.info "Droonga::Plugins::SampleLoggerPlugin", :message => message + end + end + end + end +end +~~~ + +Restart `fluentd`: + +~~~ +# kill $(cat fluentd.pid) +# RUBYLIB=./lib fluentd --config fluentd.conf --log fluentd.log --daemon fluentd.pid +~~~ + +Let's send a request to Droonga Engine. +Here, we use the first line of `stores.json`. + +add-store.json: + +~~~ +{"dataset":"Starbucks","type":"add","body":{"table":"Store","key":"1st Avenue & 75th St. - New York NY (W)","values":{"location":"40.770262,-73.954798"}}} +~~~ + +Send it to the engine: + +~~~ +# droonga-request --tag starbucks add-store.json +~~~ + +You will see no output for `droonga-request` execution because out `sample-logger` plugin traps the `add` request. + +Instead, you will see results like this in `fluentd.log`: + +~~~ +2014-02-17 16:29:18 +0900 [info]: Droonga::Plugins::SampleLoggerPlugin message=#<Droonga::HandlerMessage:0x007f7f6a66c4c0 @raw={"dataset"=>"Starbucks", "type"=>"add", "body"=>{"id"=>"localhost:24224/starbucks.#2", "task"=>{"route"=>"localhost:24224/starbucks.000", "step"=>{"command"=>"add", "dataset"=>"Starbucks", "body"=>{"table"=>"Store", "key"=>"1st Avenue & 75th St. - New York NY (W)", "values"=>{"location"=>"40.770262,-73.954798"}}, "key"=>"1st Avenue & 75th St. - New York NY (W)", "type"=>"scatter", "outputs"=>["errors", "success"], "replica"=>"all", "post"=>true, "routes"=>["localhost:24224/starbucks.000", "localhost:24224/starbucks.001"], "n_of_expects"=>0, "descendants"=>{"errors"=>["localhost:24224/starbucks.#2"], "success"=>["localhost:24224/starbucks.#2"]}}, "n_of_inputs"=>0, "values"=>{}}, "descendants"=>{"errors"=>["localhost:24224/starbucks"], "success"=>["localhost:24224/starbucks"]}}, "replyTo"=>{"type"=>"add.result", "to"=>"127.0.0.1:50480/droonga"}, "id" =>"13926 22158.374441", "date"=>"2014-02-17 16:29:18 +0900", "appliedAdapters"=>["Droonga::Plugins::CRUD::Adapter", "Droonga::Plugins::Error::Adapter"]}, @body={"id"=>"localhost:24224/starbucks.#2", "task"=>{"route"=>"localhost:24224/starbucks.000", "step"=>{"command"=>"add", "dataset"=>"Starbucks", "body"=>{"table"=>"Store", "key"=>"1st Avenue & 75th St. - New York NY (W)", "values"=>{"location"=>"40.770262,-73.954798"}}, "key"=>"1st Avenue & 75th St. - New York NY (W)", "type"=>"scatter", "outputs"=>["errors", "success"], "replica"=>"all", "post"=>true, "routes"=>["localhost:24224/starbucks.000", "localhost:24224/starbucks.001"], "n_of_expects"=>0, "descendants"=>{"errors"=>["localhost:24224/starbucks.#2"], "success"=>["localhost:24224/starbucks.#2"]}}, "n_of_inputs"=>0, "values"=>{}}, "descendants"=>{"errors"=>["localhost:24224/starbucks"], "success"=>["localhost:24224/starbucks"]}}, @task={"route"=>"localhost:24224/starbucks.000", "step"=>{"command"=>"add", "dataset"=>"Starbuck s", "bod y"=>{"table"=>"Store", "key"=>"1st Avenue & 75th St. - New York NY (W)", "values"=>{"location"=>"40.770262,-73.954798"}}, "key"=>"1st Avenue & 75th St. - New York NY (W)", "type"=>"scatter", "outputs"=>["errors", "success"], "replica"=>"all", "post"=>true, "routes"=>["localhost:24224/starbucks.000", "localhost:24224/starbucks.001"], "n_of_expects"=>0, "descendants"=>{"errors"=>["localhost:24224/starbucks.#2"], "success"=>["localhost:24224/starbucks.#2"]}}, "n_of_inputs"=>0, "values"=>{}}, @step={"command"=>"add", "dataset"=>"Starbucks", "body"=>{"table"=>"Store", "key"=>"1st Avenue & 75th St. - New York NY (W)", "values"=>{"location"=>"40.770262,-73.954798"}}, "key"=>"1st Avenue & 75th St. - New York NY (W)", "type"=>"scatter", "outputs"=>["errors", "success"], "replica"=>"all", "post"=>true, "routes"=>["localhost:24224/starbucks.000", "localhost:24224/starbucks.001"], "n_of_expects"=>0, "descendants"=>{"errors"=>["localhost:24224/starbucks.#2"], "success"=>["localhost:2 4224/sta rbucks.#2"]}}> +2014-02-17 16:29:18 +0900 [info]: Droonga::Plugins::SampleLoggerPlugin message=#<Droonga::HandlerMessage:0x007f7f6a65ff40 @raw={"dataset"=>"Starbucks", "type"=>"add", "body"=>{"id"=>"localhost:24224/starbucks.#2", "task"=>{"route"=>"localhost:24224/starbucks.001", "step"=>{"command"=>"add", "dataset"=>"Starbucks", "body"=>{"table"=>"Store", "key"=>"1st Avenue & 75th St. - New York NY (W)", "values"=>{"location"=>"40.770262,-73.954798"}}, "key"=>"1st Avenue & 75th St. - New York NY (W)", "type"=>"scatter", "outputs"=>["errors", "success"], "replica"=>"all", "post"=>true, "routes"=>["localhost:24224/starbucks.000", "localhost:24224/starbucks.001"], "n_of_expects"=>0, "descendants"=>{"errors"=>["localhost:24224/starbucks.#2"], "success"=>["localhost:24224/starbucks.#2"]}}, "n_of_inputs"=>0, "values"=>{}}, "descendants"=>{"errors"=>["localhost:24224/starbucks"], "success"=>["localhost:24224/starbucks"]}}, "replyTo"=>{"type"=>"add.result", "to"=>"127.0.0.1:50480/droonga"}, "id" =>"13926 22158.374441", "date"=>"2014-02-17 16:29:18 +0900", "appliedAdapters"=>["Droonga::Plugins::CRUD::Adapter", "Droonga::Plugins::Error::Adapter"]}, @body={"id"=>"localhost:24224/starbucks.#2", "task"=>{"route"=>"localhost:24224/starbucks.001", "step"=>{"command"=>"add", "dataset"=>"Starbucks", "body"=>{"table"=>"Store", "key"=>"1st Avenue & 75th St. - New York NY (W)", "values"=>{"location"=>"40.770262,-73.954798"}}, "key"=>"1st Avenue & 75th St. - New York NY (W)", "type"=>"scatter", "outputs"=>["errors", "success"], "replica"=>"all", "post"=>true, "routes"=>["localhost:24224/starbucks.000", "localhost:24224/starbucks.001"], "n_of_expects"=>0, "descendants"=>{"errors"=>["localhost:24224/starbucks.#2"], "success"=>["localhost:24224/starbucks.#2"]}}, "n_of_inputs"=>0, "values"=>{}}, "descendants"=>{"errors"=>["localhost:24224/starbucks"], "success"=>["localhost:24224/starbucks"]}}, @task={"route"=>"localhost:24224/starbucks.001", "step"=>{"command"=>"add", "dataset"=>"Starbuck s", "bod y"=>{"table"=>"Store", "key"=>"1st Avenue & 75th St. - New York NY (W)", "values"=>{"location"=>"40.770262,-73.954798"}}, "key"=>"1st Avenue & 75th St. - New York NY (W)", "type"=>"scatter", "outputs"=>["errors", "success"], "replica"=>"all", "post"=>true, "routes"=>["localhost:24224/starbucks.000", "localhost:24224/starbucks.001"], "n_of_expects"=>0, "descendants"=>{"errors"=>["localhost:24224/starbucks.#2"], "success"=>["localhost:24224/starbucks.#2"]}}, "n_of_inputs"=>0, "values"=>{}}, @step={"command"=>"add", "dataset"=>"Starbucks", "body"=>{"table"=>"Store", "key"=>"1st Avenue & 75th St. - New York NY (W)", "values"=>{"location"=>"40.770262,-73.954798"}}, "key"=>"1st Avenue & 75th St. - New York NY (W)", "type"=>"scatter", "outputs"=>["errors", "success"], "replica"=>"all", "post"=>true, "routes"=>["localhost:24224/starbucks.000", "localhost:24224/starbucks.001"], "n_of_expects"=>0, "descendants"=>{"errors"=>["localhost:24224/starbucks.#2"], "success"=>["localhost:2 4224/sta rbucks.#2"]}}> +~~~ + +In `add` case, two log lines are shown for one request. This is because we have configured to have two replicas for each partition. + +In order to be consistent, `add` command must reach all of the replicas of the partition, but not the other partitions. +As a consequence, `localhost:24224/starbucks.000` and `localhost:24224/starbucks.001` are chosen. + + +## まとめ + +We have learned how to create plugins work in handling phrase. + + + [adapter]: ../adapter + [basic]: ../basic