YUKI Hiroshi
null+****@clear*****
Fri Feb 7 19:39:34 JST 2014
YUKI Hiroshi 2014-02-07 19:39:34 +0900 (Fri, 07 Feb 2014) New Revision: ef70d4b4432ed64b26c5878f5bed53e8b5aa33a6 https://github.com/droonga/droonga.org/commit/ef70d4b4432ed64b26c5878f5bed53e8b5aa33a6 Message: Update translations around tutorial Added files: _po/ja/tutorial/basic/index.po Copied files: ja/tutorial/basic/index.md (from ja/tutorial/index.md) Modified files: _po/ja/tutorial/index.po ja/tutorial/index.md tutorial/index.md Added: _po/ja/tutorial/basic/index.po (+421 -0) 100644 =================================================================== --- /dev/null +++ _po/ja/tutorial/basic/index.po 2014-02-07 19:39:34 +0900 (bc0d430) @@ -0,0 +1,421 @@ +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-07 19:31+0900\n" +"Last-Translator: YUKI Hiroshi <piro.outsider.reflex �� gmail.com>\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: Droonga tutorial: basic usage\n" +"layout: en\n" +"---" +msgstr "" +"---\n" +"title: Droonga チュートリアル: 基本的な使い方\n" +"layout: ja\n" +"---" + +msgid "" +"* TOC\n" +"{:toc}" +msgstr "" + +msgid "## The goal of this tutorial" +msgstr "## チュートリアルのゴール" + +msgid "Learning steps to setup a Droonga based search system by yourself." +msgstr "Droonga を使った検索システムを自分で構築できるようになる。" + +msgid "## Precondition" +msgstr "## 前提条件" + +msgid "" +"* You must have basic knowledges and experiences how setup and operate an [Ubu" +"ntu][] Server.\n" +"* You must have basic knowledges and experiences to develop applications based" +" on the [Ruby][] and the [Node.js][]." +msgstr "" +"* [Ubuntu][] Server を自分でセットアップしたり、基本的な操作ができること\n" +"* [Ruby][] と [Node.js][] の基本的な知識があること" + +msgid "## Abstract" +msgstr "## 概要" + +msgid "### What is the Droonga?" +msgstr "### Droonga とは" + +msgid "" +"It is a data processing engine based on a distributed architecture, named afte" +"r the terms \"distributed-Groonga\"." +msgstr "分散データ処理エンジンです。 \"distributed-groonga\" に由来します。" + +msgid "" +"The Droonga is built on some components which are made as separated packages. " +"You can develop various data processing systems (for example, a fulltext searc" +"h engine) with high scalability from a distributed architecture, with those pa" +"ckages." +msgstr "" +"Droonga は複数のコンポーネントから構成されています。ユーザは、これらのパッケージを組み合わせて利用することで、全文検索をはじめとするスケーラブルな分" +"散データ処理システムを構築することができます。" + +msgid "### Components of the Droonga" +msgstr "### Droonga を構成するコンポーネント" + +msgid "" +"The component \"Droonga Engine\" is the main part to process data with a distrib" +"uted architecture. It is triggered by requests and processes various data." +msgstr "Droonga Engine は Droonga における分散データ処理の要となるコンポーネントです。リクエストに基いて実際のデータ処理を行います。" + +msgid "" +"This component is developed as a [Fluentd] plugin, and released as the [fluent" +"-plugin-droonga][] package.\n" +"It internally uses [Groonga][] as its search engine. Groonga is an open source" +", fulltext search engine, including a column-store feature." +msgstr "" +"このコンポーネントは [Fluentd] のプラグインとして実装されており、 [fluent-plugin-droonga][] パッケージとして提供されま" +"す。\n" +"[fluent-plugin-droonga][] は検索エンジンとして、オープンソースのカラムストア機能付き全文検索エンジン [Groonga][] を使" +"用しています。" + +msgid "" +"The component \"Protocol Adapter\" provides ability for clients to communicate w" +"ith a Droonga engine, using various protocols." +msgstr "Protocol Adapter は、Droonga を様々なプロトコルで利用できるようにするためのアダプタです。" + +msgid "" +"This component is developed as a module for the [Node.js][], and released as t" +"he [express-droonga][] package." +msgstr "このコンポーネントは [Node.js][] のパッケージとして実装されており、[express-droonga][] パッケージとして提供されます。" + +msgid "" +"The only one available protocol of a Droonga engine is the fluentd protocol. I" +"nstead, a protocol adapter provides various interfaces, HTTP, Socket.IO, and s" +"o on, for applications, between them and a Droonga engine." +msgstr "" +"Droonga Engine は fluentd プロトコルで通信を行います。Protocol Adapter は、ユーザがアプリケーションを構築する際に利" +"用しやすいよう、 Droonga Engine の機能を HTTP や Socket.IO などのインタフェースで提供します。" + +msgid "## Abstract of the system described in this tutorial" +msgstr "## チュートリアルでつくるシステムの全体像" + +msgid "This tutorial describes steps to build a system like following:" +msgstr "チュートリアルでは、以下の様な構成のシステムを構築します。" + +msgid "" +" \\--------------------------------------------" +"------/\n" +" This tutorial describes about this part" +"." +msgstr "" +" \\--------------------------------------------" +"------/\n" +" この部分を構築します" + +msgid "" +"User agents (ex. a Web browser) sends search requests to a protocol adapter. T" +"he adapter receives them, and sends internal (translated) search requests to a" +" Droonga engine. The engine processes them actually. Search results are sent f" +"rom the engine to the protocol adapter, and finally delivered to the user agen" +"t." +msgstr "" +"ユーザは Protocol Adapter に、Web ブラウザなどを用いて接続します。Protocol Adapter は Droonga Engine " +"へリクエストを送信します。実際の検索処理は Droonga Engine が行います。検索結果は、Droonga Engine から Protocol Ad" +"apter に渡され、最終的にユーザに返ります。" + +msgid "" +"For example let's try to build a database system to find [Starbucks stores in " +"New York](http://geocommons.com/overlays/430038)." +msgstr "" +"例として、[ニューヨークにあるのスターバックスの店舗](http://geocommons.com/overlays/430038)を検索できるデータベース" +"システムを作成することにします。" + +msgid "## Prepare an environment for experiments" +msgstr "## 実験用のマシンを用意する" + +msgid "" +"Prepare a computer at first. This tutorial describes steps to develop a search" +" service based on the Droonga, on an existing computer.\n" +"Following instructions are basically written for a successfully prepared virtu" +"al machine of the `Ubuntu 13.10 x64` on the service [DigitalOcean](https://www" +".digitalocean.com/), with an available console." +msgstr "" +"まずコンピュータを調達しましょう。このチュートリアルでは、既存のコンピュータにDroongaによる検索システムを構築する手順を解説します。\n" +"以降の説明は基本的に、[DigitalOcean](https://www.digitalocean.com/)で `Ubuntu 13.10 x64` の" +"仮想マシンのセットアップを完了し、コンソールにアクセスできる状態になった後を前提として進めます。" + +msgid "" +"NOTE: Make sure to use instances with >= 2GB memory equipped, at least during " +"installation of required packages for Droonga. Otherwise, you may experience a" +" strange build error." +msgstr "" +"注意:Droongaが必要とするパッケージをインストールする前に、マシンが2GB以上のメモリを備えていることを確認して下さい。メモリが不足していると、ビルド" +"時にエラーが出て、ビルドに失敗することがあります。" + +msgid "## Install packages required for the setup process" +msgstr "## セットアップに必要なパッケージをインストールする" + +msgid "Install packages required to setup a Droonga engine." +msgstr "Droonga をセットアップするために必要になるパッケージをインストールします。" + +msgid "## Build a Droonga engine" +msgstr "## Droonga Engine を構築する" + +msgid "" +"The part \"Droonga engine\" stores the database and provides the search feature " +"actually.\n" +"In this section we install a fluent-plugin-droonga and load searchable data to" +" the database." +msgstr "" +"Droonga Engine は、データベースを保持し、実際の検索を担当する部分です。\n" +"このセクションでは、 fluent-plugin-droonga をインストールし、検索対象となるデータを準備します。" + +msgid "### Install a fluent-plugin-droonga" +msgstr "### fluent-plugin-droonga をインストールする" + +msgid "" +"Required packages are prepared by the command above. Let's continue to the con" +"figuration step." +msgstr "Droonga Engine を構築するのに必要なパッケージがセットアップできました。引き続き設定に移ります。" + +msgid "### Prepare a configuration file to start a Droonga engine" +msgstr "### Droonga Engine を起動するための設定ファイルを用意する" + +msgid "Create a directory for a Droonga engine:" +msgstr "まず Droonga Engine 用のディレクトリを作成します。" + +msgid "" +"Next, put configuration files `fluentd.conf` and `catalog.json` like following" +", into the directory:" +msgstr "以下の内容で `fluentd.conf` と `catalog.json` を作成します。" + +msgid "" +"This `catalog.json` defines a dataset `Starbucks` with two replicas and two pa" +"rtitions.\n" +"All of replicas and partitions are stored locally (in other words, they are ma" +"naged by a `fluent-plugin-droonga` instance)." +msgstr "" +"この `catalog.json` では、 `Starbucks` データセットを定義し、2組のレプリカ×2個のパーティションで構成するよう指示しています。" +"\n" +"この例では、全てのレプリカ及びパーティションは、ローカル(一つの `fluent-plugin-droonga` の管理下)に配置します。" + +msgid "" +"For more details of the configuration file `catalog.json`, see [the reference " +"manual of catalog.json](/reference/catalog)." +msgstr "`catalog.json` の詳細については [catalog.json](/ja/reference/catalog) を参照してください。" + +msgid "### Start an instance of fluent-plugin-droonga" +msgstr "### fluent-plugin-droonga を起動する" + +msgid "" +"Start a Droonga engine, it is a fluentd server with fluentd-plugin-droonga sta" +"rted like:" +msgstr "以下のようにして fluentd-plugin-droonga を起動します。" + +msgid "### Create a database" +msgstr "### データベースを作成する" + +msgid "" +"After a Droonga engine is started, let's load data.\n" +"Prepare two jsons files, `ddl.jsons` including the database schema and `stores" +".jsons` including location data of stores." +msgstr "" +"Dronga Engine が起動したので、データを投入しましょう。\n" +"スキーマを定義した `ddl.jsons` と、店舗のデータ `stores.jsons` を用意します。" + +msgid "" +"Open another terminal to keep the fluentd server working, and send those two j" +"sons `ddl.jsons` and `stores.jsons` to the fluentd server:" +msgstr "fluentd を起動した状態で別の端末を開き、以下のようにして `ddl.jsons` と `stores.jsons` を投入します:" + +msgid "" +"Now a Droonga engine for searching Starbucks stores database is ready.\n" +"Next, setup a protocol adapter for clients to accept search requests using pop" +"ular protocols." +msgstr "" +"これで、スターバックスの店舗のデータベースを検索するための Droonga Engine ができました。\n" +"引き続き Protocol Adapter を構築して、検索リクエストを受け付けられるようにしましょう。" + +msgid "## Build a protocol adapter" +msgstr "## Protocol Adapter を構築する" + +msgid "" +"Let's use the `express-droonga` to build a protocol adapter. It is an npm pack" +"age for the Node.js." +msgstr "" +"Protocol Adapter を構築するために、 `express-droonga` を使用します。 `express-droonga` は、Node." +"js のパッケージです。" + +msgid "### Install a express-droonga" +msgstr "### express-droonga をインストールする" + +msgid "After that, put a file `package.json` like following, into the directory:" +msgstr "以下のような `package.json` を用意します。" + +msgid "Install depending packages." +msgstr "必要なパッケージをインストールします。" + +msgid "### Create a protocol adapter" +msgstr "### Protocol Adapter を作成する" + +msgid "Put a file `application.js` like following, into the directory:" +msgstr "以下のような内容で `application.js` を作成します。" + +msgid "Then, run the `application.js`." +msgstr "`application.js` を実行します。" + +msgid "### Synchronous search request via HTTP" +msgstr "### HTTPでの同期的な検索のリクエスト" + +msgid "" +"We're all set. Let's send a search request to the protocol adapter via HTTP. A" +"t first, try to get all records of the `Stores` table by a request like follow" +"ing. (Note: The `attributes=_key` parameter means \"export the value of the col" +"umn `_key` to the search result\". If you don't set the parameter, each record " +"returned in the `records` will become just a blank array. You can specify mult" +"iple column names by the delimiter `,`. For example `attributes=_key,location`" +" will return both the primary key and the location for each record.)" +msgstr "" +"準備が整いました。 Protocol Adapter に向けて HTTP 経由でリクエストを発行し、データベースに問い合わせを行ってみましょう。まずは `S" +"hops` テーブルの中身を取得してみます。以下のようなリクエストを用います。(`attributes=_key` を指定しているのは「検索結果に `_ke" +"y` 値を含めて返してほしい」という意味です。これがないと、`records` に何も値がないレコードが返ってきてしまいます。`attributes` パラ" +"メータには `,` 区切りで複数の属性を指定することができます。`attributes=_key,location` と指定することで、緯度経度もレスポンス" +"として受け取ることができます)" + +msgid "" +"Because the `count` says `40`, you know there are all 40 records in the table." +" Search result records are returned as an array `records`." +msgstr "`count` の値からデータが全部で 36 件あることがわかります。`records` に配列として検索結果が入っています。" + +msgid "" +"Next step, let's try more meaningful query. To search stores which contain \"Co" +"lumbus\" in their name, give `Columbus` as the parameter `query`, and give `_ke" +"y` as the parameter `match_to` which means the column to be searched. Then:" +msgstr "" +"もう少し複雑なクエリを試してみましょう。例えば、店名に「Columbus」を含む店舗を検索します。`query` パラメータにクエリ `Columbus` " +"を、`match_to` パラメータに検索対象として `_key` を指定し、以下のようなリクエストを発行します。" + +msgid "As the result two stores are found by the search condition." +msgstr "以上 2 件が検索結果として該当することがわかりました。" + +msgid "### Asynchronous search request via Socket.IO" +msgstr "### Socket.IO を用いた非同期処理" + +msgid "" +"A Droonga protocol adapter supports not only REST API, but also [Socket.IO][]." +" If you send a request to a protocol adapter via Socket.IO, then the protocol " +"adapter sends back the response for the request after the operation is finishe" +"d. So you can develop a system based on a client application and an API server" +" communicating each other asynchronously." +msgstr "" +"Droonga の Protocol Adapter は、 REST API だけでなく、 [Socket.IO][] にも対応しています。Socket.I" +"O 経由で Protocol Adapter へリクエストを送ると、処理が完了した時点で Protocol Adapter から結果を送り返してもらえます。" +"この仕組を利用すると、クライアントアプリケーションと Droonga の間でリクエストとレスポンスを別々に送り合う、非同期な通信を行うことができます。" + +msgid "Now, let's create such a system based on Socket.IO." +msgstr "" +"ここでは、Webブラウザを「クライアントアプリケーション」とし、Protocol Adapter との間で Socket.IO を利用して通信するアプリケー" +"ションを作成してみましょう。" + +msgid "" +"The sample client application is a simple Web page `index.html` loaded in a We" +"b browser, returned by the protocol adapter itself.\n" +"Put a file `index.html` into the `protocol-adaptor` directory, like following:" +msgstr "" +"Protocol Adapter から `index.html` を配信し、Webブラウザに渡すことにしましょう。\n" +"`protocol-adapter` ディレクトリの下に以下の内容の `index.html` を配置します。" + +msgid "" +"This client sends a search query by `socket.emit()`. After the request is proc" +"essed and the result is returned, the callback given as `socket.on('search.res" +"ult', ...)` will be called with the result, and it will render the result to t" +"he page." +msgstr "" +"`socket.emit()` でクエリを送信します。クエリの処理が完了し、結果が戻ってくると、 `socket.on('search.result', ." +"..)` のコールバックが呼ばれ、ページ内にその結果が表示されます。" + +msgid "" +"The first argument `'search'` for the method call `socket.emit()` means that t" +"he request is a search request.\n" +"The second argument includes parameters of the search request. See the command" +" reference of the [`search` command](/reference/commands/search) for more deta" +"ils.\n" +"(By the way, we used a REST API to do search in the previous section. In the c" +"ase the protocol adapter translates a HTTP request to a message in the format " +"described in the [command reference of the `search`](/reference/commands/searc" +"h) internally and sends it to the Droonga engine.)" +msgstr "" +"`socket.emit()` の第1引数 `'search'` は、このリクエストが検索リクエストであることを指定しています。\n" +"第2引数でどのような検索を行うかを指定しています。\n" +"詳しくは [search](/ja/reference/commands/search) を参照してください。\n" +"ところで、前のセクションでは、REST API を利用して検索を行いました。\n" +"REST API を利用した場合は、 `express-droonga` が内部で REST リクエストから上記の形式のメッセージへと変換し、`fluent" +"-plugin-droonga` に送信するようになっています。" + +msgid "" +"Next, modify the `application.js` to host the `index.html` by the protocol ada" +"pter, like:" +msgstr "" +"では、この `index.html` を Protocol Adapter でホストできるようにするため、`application.js` を以下のように書" +"き換えます。" + +msgid "" +"Then, type the IP address of the server for experiments into the address bar o" +"f your Web browser. For example, if the IP address is `192.0.2.1`, then the lo" +"cation is `http://192.0.2.1:3000/` and you can see the contents of the `index." +"html`. When you see the search result like following, then the search request " +"is successfully processed:" +msgstr "" +"Web ブラウザにサーバの IP アドレスを入れて、リクエストを送信してみましょう。\n" +"以降、サーバの IP アドレスが `192.0.2.1` であったとします。\n" +"`http://192.0.2.1:3000/` をリクエストすると、先の `index.html` が返されるようになります。\n" +"Webブラウザから `http://192.0.2.1:3000` を開いてみてください。以下のように検索結果が表示されれば成功です。" + +msgid "" +"Your Web browser sends a request to the protocol adapter via Socket.IO, the pr" +"otocol adapter sends it to the Droonga engine via fluent protocol, the engine " +"returns the search result to the protocol adapter, and the protocol adapter se" +"nds back the search result to the client." +msgstr "" +"Web ブラウザから Socket.IO 経由でリクエストが Protocol Adapter に送信され、それが Engine に送られ、検索結果が Pr" +"otocol Adapter に返され、さらに Web ブラウザに返されます。" + +msgid "" +"Next, try a fulltext search request like the previous section, to find stores " +"with the town name \"Columbus\".\n" +"Modify the parameter given to the `socket.emit()` method in the `index.html`, " +"like following:" +msgstr "" +"今度は全文検索を行ってみましょう。先ほどと同様に「Columbus」を店名に含む店舗を検索します。`index.html` の `socket.emit()" +"` の呼び出しを書き換え、以下の様な `index.html` を用意します。" + +msgid "" +"Reload the current page `http://192.0.2.1:3000` in your Web browser, then you'" +"ll see a search result like following:" +msgstr "ブラウザで再度 `http://192.0.2.1:3000` を開くと、以下のような検索結果が表示されます。" + +msgid "" +"OK, you've successfully created a client application which can send search req" +"uests and receive responses asynchronously via Socket.IO." +msgstr "このように、Socket.IO を利用して、リクエストとレスポンスを非同期に送受信する検索クライアントを作成することができました。" + +msgid "## Conclusion" +msgstr "## まとめ" + +msgid "" +"In this tutorial, you did setup both packages [fluent-plugin-droonga][] and [e" +"xpress-droonga][] which construct [Droonga][] service on a [Ubuntu Linux][Ubun" +"tu].\n" +"Moreover, you built a search system based on a protocol adapter with a Droonga" +" engine, and successfully searched." +msgstr "" +"[Ubuntu Linux][Ubuntu] 上に [Droonga][] を構成するパッケージである [fluent-plugin-droonga][] " +"と [express-droonga][] をセットアップしました。\n" +"これらのパッケージを利用することで、Protocol Adapter と Droonga Engine からなるシステムを構築し、実際に検索を行いました。" Modified: _po/ja/tutorial/index.po (+9 -1002) =================================================================== --- _po/ja/tutorial/index.po 2014-02-07 19:30:31 +0900 (c314aa1) +++ _po/ja/tutorial/index.po 2014-02-07 19:39:34 +0900 (2ab9c07) @@ -3,7 +3,7 @@ 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: 2013-12-19 14:53+0900\n" +"PO-Revision-Date: 2013-12-25 18:27+0900\n" "Last-Translator: Kouhei Sutou <kou �� clear-code.com>\n" "Language-Team: Japanese\n" "Language: ja\n" @@ -28,1007 +28,14 @@ msgid "" "{:toc}" msgstr "" -msgid "## The goal of this tutorial" -msgstr "## チュートリアルのゴール" +msgid "## For application developers" +msgstr "## アプリケーション開発者向け" -msgid "Learning steps to setup a Droonga based search system by yourself." -msgstr "Droonga を使った検索システムを自分で構築できるようになる。" +msgid " * [Basic usage tutorial](basic/)" +msgstr " * [基本的な使い方のチュートリアル](basic/)" -msgid "## Precondition" -msgstr "## 前提条件" +msgid "## For plugin developers" +msgstr "## プラグイン開発者向け" -msgid "" -"* You must have basic knowledges and experiences how setup and operate an [Ubu" -"ntu][] Server.\n" -"* You must have basic knowledges and experiences to develop applications based" -" on the [Ruby][] and the [Node.js][]." -msgstr "" -"* [Ubuntu][] Server を自分でセットアップしたり、基本的な操作ができること\n" -"* [Ruby][] と [Node.js][] の基本的な知識があること" - -msgid "## Abstract" -msgstr "## 概要" - -msgid "### What is the Droonga?" -msgstr "### Droonga とは" - -msgid "" -"It is a data processing engine based on a distributed architecture, named afte" -"r the terms \"distributed-Groonga\"." -msgstr "分散データ処理エンジンです。 \"distributed-groonga\" に由来します。" - -msgid "" -"The Droonga is built on some components which are made as separated packages. " -"You can develop various data processing systems (for example, a fulltext searc" -"h engine) with high scalability from a distributed architecture, with those pa" -"ckages." -msgstr "" -"Droonga は複数のコンポーネントから構成されています。ユーザは、これらのパッケージを組み合わせて利用することで、全文検索をはじめとするスケーラブルな分" -"散データ処理システムを構築することができます。" - -msgid "### Components of the Droonga" -msgstr "### Droonga を構成するコンポーネント" - -msgid "#### Droonga Engine" -msgstr "" - -msgid "" -"The component \"Droonga Engine\" is the main part to process data with a distrib" -"uted architecture. It is triggered by requests and processes various data." -msgstr "Droonga Engine は Droonga における分散データ処理の要となるコンポーネントです。リクエストに基いて実際のデータ処理を行います。" - -msgid "" -"This component is developed as a [Fluentd] plugin, and released as the [fluent" -"-plugin-droonga][] package.\n" -"It internally uses [Groonga][] as its search engine. Groonga is an open source" -", fulltext search engine, including a column-store feature." -msgstr "" -"このコンポーネントは [Fluentd] のプラグインとして実装されており、 [fluent-plugin-droonga][] パッケージとして提供されま" -"す。\n" -"[fluent-plugin-droonga][] は検索エンジンとして、オープンソースのカラムストア機能付き全文検索エンジン [Groonga][] を使" -"用しています。" - -msgid "#### Protocol Adapter" -msgstr "" - -msgid "" -"The component \"Protocol Adapter\" provides ability for clients to communicate w" -"ith a Droonga engine, using various protocols." -msgstr "Protocol Adapter は、Droonga を様々なプロトコルで利用できるようにするためのアダプタです。" - -msgid "" -"This component is developed as a module for the [Node.js][], and released as t" -"he [express-droonga][] package." -msgstr "このコンポーネントは [Node.js][] のパッケージとして実装されており、[express-droonga][] パッケージとして提供されます。" - -msgid "" -"The only one available protocol of a Droonga engine is the fluentd protocol. I" -"nstead, a protocol adapter provides various interfaces, HTTP, Socket.IO, and s" -"o on, for applications, between them and a Droonga engine." -msgstr "" -"Droonga Engine は fluentd プロトコルで通信を行います。Protocol Adapter は、ユーザがアプリケーションを構築する際に利" -"用しやすいよう、 Droonga Engine の機能を HTTP や Socket.IO などのインタフェースで提供します。" - -msgid "## Abstract of the system described in this tutorial" -msgstr "## チュートリアルでつくるシステムの全体像" - -msgid "This tutorial describes steps to build a system like following:" -msgstr "チュートリアルでは、以下の様な構成のシステムを構築します。" - -msgid "" -" +-------------+ +------------------+ +-----------" -"-----+\n" -" | Web Browser | <--------> | Protocol Adapter | <-------> | Droonga En" -"gine |\n" -" +-------------+ HTTP / +------------------+ Fluent +-----------" -"-----+\n" -" Socket.IO w/express-droonga protocol w/fluent-pl" -"ugin\n" -" -dr" -"oonga" -msgstr "" - -msgid "" -" \\--------------------------------------------" -"------/\n" -" This tutorial describes about this part" -"." -msgstr "" -" \\--------------------------------------------" -"------/\n" -" この部分を構築します" - -msgid "" -"User agents (ex. a Web browser) sends search requests to a protocol adapter. T" -"he adapter receives them, and sends internal (translated) search requests to a" -" Droonga engine. The engine processes them actually. Search results are sent f" -"rom the engine to the protocol adapter, and finally delivered to the user agen" -"t." -msgstr "" -"ユーザは Protocol Adapter に、Web ブラウザなどを用いて接続します。Protocol Adapter は Droonga Engine " -"へリクエストを送信します。実際の検索処理は Droonga Engine が行います。検索結果は、Droonga Engine から Protocol Ad" -"apter に渡され、最終的にユーザに返ります。" - -msgid "" -"For example let's try to build a database system to find [Starbucks stores in " -"New York](http://geocommons.com/overlays/430038)." -msgstr "" -"例として、[ニューヨークにあるのスターバックスの店舗](http://geocommons.com/overlays/430038)を検索できるデータベース" -"システムを作成することにします。" - -msgid "## Prepare an environment for experiments" -msgstr "## 実験用のマシンを用意する" - -msgid "" -"Prepare a computer at first. This tutorial describes steps to develop a search" -" service based on the Droonga, on an existing computer.\n" -"Following instructions are basically written for a successfully prepared virtu" -"al machine of the `Ubuntu 13.10 x64` on the service [DigitalOcean](https://www" -".digitalocean.com/), with an available console." -msgstr "" -"まずコンピュータを調達しましょう。このチュートリアルでは、既存のコンピュータにDroongaによる検索システムを構築する手順を解説します。\n" -"以降の説明は基本的に、[DigitalOcean](https://www.digitalocean.com/)で `Ubuntu 13.10 x64` の" -"仮想マシンのセットアップを完了し、コンソールにアクセスできる状態になった後を前提として進めます。" - -msgid "" -"NOTE: Make sure to use instances with >= 2GB memory equipped, at least during " -"installation of required packages for Droonga. Otherwise, you may experience a" -" strange build error." -msgstr "" -"注意:Droongaが必要とするパッケージをインストールする前に、マシンが2GB以上のメモリを備えていることを確認して下さい。メモリが不足していると、ビルド" -"時にエラーが出て、ビルドに失敗することがあります。" - -msgid "## Install packages required for the setup process" -msgstr "## セットアップに必要なパッケージをインストールする" - -msgid "Install packages required to setup a Droonga engine." -msgstr "Droonga をセットアップするために必要になるパッケージをインストールします。" - -msgid "" -" # apt-get update\n" -" # apt-get -y upgrade\n" -" # apt-get install -y ruby ruby-dev build-essential nodejs npm" -msgstr "" - -msgid "## Build a Droonga engine" -msgstr "## Droonga Engine を構築する" - -msgid "" -"The part \"Droonga engine\" stores the database and provides the search feature " -"actually.\n" -"In this section we install a fluent-plugin-droonga and load searchable data to" -" the database." -msgstr "" -"Droonga Engine は、データベースを保持し、実際の検索を担当する部分です。\n" -"このセクションでは、 fluent-plugin-droonga をインストールし、検索対象となるデータを準備します。" - -msgid "### Install a fluent-plugin-droonga" -msgstr "### fluent-plugin-droonga をインストールする" - -msgid " # gem install fluent-plugin-droonga" -msgstr "" - -msgid "" -"Required packages are prepared by the command above. Let's continue to the con" -"figuration step." -msgstr "Droonga Engine を構築するのに必要なパッケージがセットアップできました。引き続き設定に移ります。" - -msgid "### Prepare a configuration file to start a Droonga engine" -msgstr "### Droonga Engine を起動するための設定ファイルを用意する" - -msgid "Create a directory for a Droonga engine:" -msgstr "まず Droonga Engine 用のディレクトリを作成します。" - -msgid "" -" # mkdir engine\n" -" # cd engine" -msgstr "" - -msgid "" -"Next, put configuration files `fluentd.conf` and `catalog.json` like following" -", into the directory:" -msgstr "以下の内容で `fluentd.conf` と `catalog.json` を作成します。" - -msgid "fluentd.conf:" -msgstr "" - -msgid "" -" <source>\n" -" type forward\n" -" port 24224\n" -" </source>\n" -" <match starbucks.message>\n" -" name localhost:24224/starbucks\n" -" type droonga\n" -" </match>\n" -" <match output.message>\n" -" type stdout\n" -" </match>" -msgstr "" - -msgid "catalog.json:" -msgstr "" - -msgid "" -" {\n" -" \"effective_date\": \"2013-09-01T00:00:00Z\",\n" -" \"zones\": [\"localhost:24224/starbucks\"],\n" -" \"farms\": {\n" -" \"localhost:24224/starbucks\": {\n" -" \"device\": \".\",\n" -" \"capacity\": 10\n" -" }\n" -" },\n" -" \"datasets\": {\n" -" \"Starbucks\": {\n" -" \"workers\": 0,\n" -" \"plugins\": [\"search\", \"groonga\", \"add\"],\n" -" \"number_of_replicas\": 2,\n" -" \"number_of_partitions\": 2,\n" -" \"partition_key\": \"_key\",\n" -" \"date_range\": \"infinity\",\n" -" \"ring\": {\n" -" \"localhost:23041\": {\n" -" \"weight\": 50,\n" -" \"partitions\": {\n" -" \"2013-09-01\": [\n" -" \"localhost:24224/starbucks.000\",\n" -" \"localhost:24224/starbucks.001\"\n" -" ]\n" -" }\n" -" },\n" -" \"localhost:23042\": {\n" -" \"weight\": 50,\n" -" \"partitions\": {\n" -" \"2013-09-01\": [\n" -" \"localhost:24224/starbucks.002\",\n" -" \"localhost:24224/starbucks.003\"\n" -" ]\n" -" }\n" -" }\n" -" }\n" -" }\n" -" },\n" -" \"options\": {\n" -" \"plugins\": [\"crud\"]\n" -" }\n" -" }" -msgstr "" - -msgid "" -"This `catalog.json` defines a dataset `Starbucks` with two replicas and two pa" -"rtitions.\n" -"All of replicas and partitions are stored locally (in other words, they are ma" -"naged by a `fluent-plugin-droonga` instance)." -msgstr "" -"この `catalog.json` では、 `Starbucks` データセットを定義し、2組のレプリカ×2個のパーティションで構成するよう指示しています。" -"\n" -"この例では、全てのレプリカ及びパーティションは、ローカル(一つの `fluent-plugin-droonga` の管理下)に配置します。" - -msgid "" -"For more details of the configuration file `catalog.json`, see [the reference " -"manual of catalog.json](/reference/catalog)." -msgstr "`catalog.json` の詳細については [catalog.json](/ja/reference/catalog) を参照してください。" - -msgid "### Start an instance of fluent-plugin-droonga" -msgstr "### fluent-plugin-droonga を起動する" - -msgid "" -"Start a Droonga engine, it is a fluentd server with fluentd-plugin-droonga sta" -"rted like:" -msgstr "以下のようにして fluentd-plugin-droonga を起動します。" - -msgid "" -" # fluentd --config fluentd.conf\n" -" 2013-11-12 14:14:20 +0900 [info]: starting fluentd-0.10.40\n" -" 2013-11-12 14:14:20 +0900 [info]: reading config file path=\"fluentd.conf\"\n" -" 2013-11-12 14:14:20 +0900 [info]: gem 'fluent-plugin-droonga' version '0.0" -".1'\n" -" 2013-11-12 14:14:20 +0900 [info]: gem 'fluentd' version '0.10.40'\n" -" 2013-11-12 14:14:20 +0900 [info]: using configuration file: <ROOT>\n" -" <source>\n" -" type forward\n" -" port 24224\n" -" </source>\n" -" <match starbucks.message>\n" -" name localhost:24224/starbucks\n" -" type droonga\n" -" </match>\n" -" <match output.message>\n" -" type stdout\n" -" </match>\n" -" </ROOT>\n" -" 2013-11-12 14:14:20 +0900 [info]: adding source type=\"forward\"\n" -" 2013-11-12 14:14:20 +0900 [info]: adding match pattern=\"starbucks.message\"" -" type=\"droonga\"\n" -" 2013-11-12 14:14:20 +0900 [info]: adding match pattern=\"output.message\" ty" -"pe=\"stdout\"\n" -" 2013-11-12 14:14:20 +0900 [info]: listening fluent socket on 0.0.0.0:24224" -msgstr "" - -msgid "### Create a database" -msgstr "### データベースを作成する" - -msgid "" -"After a Droonga engine is started, let's load data.\n" -"Prepare two jsons files, `ddl.jsons` including the database schema and `stores" -".jsons` including location data of stores." -msgstr "" -"Dronga Engine が起動したので、データを投入しましょう。\n" -"スキーマを定義した `ddl.jsons` と、店舗のデータ `stores.jsons` を用意します。" - -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\"}}" -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 to keep the fluentd server working, and send those two j" -"sons `ddl.jsons` and `stores.jsons` to the fluentd server:" -msgstr "fluentd を起動した状態で別の端末を開き、以下のようにして `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" -"Next, setup a protocol adapter for clients to accept search requests using pop" -"ular protocols." -msgstr "" -"これで、スターバックスの店舗のデータベースを検索するための Droonga Engine ができました。\n" -"引き続き Protocol Adapter を構築して、検索リクエストを受け付けられるようにしましょう。" - -msgid "## Build a protocol adapter" -msgstr "## Protocol Adapter を構築する" - -msgid "" -"Let's use the `express-droonga` to build a protocol adapter. It is an npm pack" -"age for the Node.js." -msgstr "" -"Protocol Adapter を構築するために、 `express-droonga` を使用します。 `express-droonga` は、Node." -"js のパッケージです。" - -msgid "### Install a express-droonga" -msgstr "### express-droonga をインストールする" - -msgid "" -" # cd ~\n" -" # mkdir protocol-adapter\n" -" # cd protocol-adapter" -msgstr "" - -msgid "After that, put a file `package.json` like following, into the directory:" -msgstr "以下のような `package.json` を用意します。" - -msgid "package.json:" -msgstr "" - -msgid "" -" {\n" -" \"name\": \"protocol-adapter\",\n" -" \"description\": \"Droonga Protocol Adapter\",\n" -" \"version\": \"0.0.0\",\n" -" \"author\": \"Droonga Project\",\n" -" \"private\": true,\n" -" \"dependencies\": {\n" -" \"express\": \"*\",\n" -" \"express-droonga\": \"*\"\n" -" }\n" -" }" -msgstr "" - -msgid "Install depending packages." -msgstr "必要なパッケージをインストールします。" - -msgid " $ npm install" -msgstr "" - -msgid "### Create a protocol adapter" -msgstr "### Protocol Adapter を作成する" - -msgid "Put a file `application.js` like following, into the directory:" -msgstr "以下のような内容で `application.js` を作成します。" - -msgid "application.js:" -msgstr "" - -msgid "" -" var express = require('express'),\n" -" droonga = require('express-droonga');" -msgstr "" - -msgid "" -" var application = express();\n" -" var server = require('http').createServer(application);\n" -" server.listen(3000); // the port to communicate with clients" -msgstr "" - -msgid "" -" application.droonga({\n" -" prefix: '/droonga',\n" -" tag: 'starbucks',\n" -" defaultDataset: 'Starbucks',\n" -" server: server, // this is required to initialize Socket.IO API!\n" -" plugins: [\n" -" droonga.API_REST,\n" -" droonga.API_SOCKET_IO,\n" -" droonga.API_GROONGA,\n" -" droonga.API_DROONGA\n" -" ]\n" -" });" -msgstr "" - -msgid "Then, run the `application.js`." -msgstr "`application.js` を実行します。" - -msgid "" -" # nodejs application.js\n" -" info - socket.io started" -msgstr "" - -msgid "### Synchronous search request via HTTP" -msgstr "### HTTPでの同期的な検索のリクエスト" - -msgid "" -"We're all set. Let's send a search request to the protocol adapter via HTTP. A" -"t first, try to get all records of the `Stores` table by a request like follow" -"ing. (Note: The `attributes=_key` parameter means \"export the value of the col" -"umn `_key` to the search result\". If you don't set the parameter, each record " -"returned in the `records` will become just a blank array. You can specify mult" -"iple column names by the delimiter `,`. For example `attributes=_key,location`" -" will return both the primary key and the location for each record.)" -msgstr "" -"準備が整いました。 Protocol Adapter に向けて HTTP 経由でリクエストを発行し、データベースに問い合わせを行ってみましょう。まずは `S" -"hops` テーブルの中身を取得してみます。以下のようなリクエストを用います。(`attributes=_key` を指定しているのは「検索結果に `_ke" -"y` 値を含めて返してほしい」という意味です。これがないと、`records` に何も値がないレコードが返ってきてしまいます。`attributes` パラ" -"メータには `,` 区切りで複数の属性を指定することができます。`attributes=_key,location` と指定することで、緯度経度もレスポンス" -"として受け取ることができます)" - -msgid "" -" # curl \"http://localhost:3000/droonga/tables/Store?attributes=_key&limit=-" -"1\"\n" -" {\n" -" \"result\": {\n" -" \"count\": 40,\n" -" \"records\": [\n" -" [\n" -" \"76th & Second - New York NY (W)\"\n" -" ],\n" -" [\n" -" \"15th & Third - New York NY (W)\"\n" -" ],\n" -" [\n" -" \"41st and Broadway - 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" -" \"Columbus @ 67th - 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" -" \"92nd & 3rd - New York NY (W)\"\n" -" ],\n" -" [\n" -" \"1656 Broadway - New York NY (W)\"\n" -" ],\n" -" [\n" -" \"19th & 8th - New York NY (W)\"\n" -" ],\n" -" [\n" -" \"60th & Broadway-II - New York NY (W)\"\n" -" ],\n" -" [\n" -" \"195 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" -" \"36th and Madison - New York NY (W)\"\n" -" ],\n" -" [\n" -" \"125th St. btwn Adam Clayton & FDB - New York NY\"\n" -" ],\n" -" [\n" -" \"2138 Broadway - New York NY (W)\"\n" -" ],\n" -" [\n" -" \"118th & Frederick Douglas Blvd. - New York NY (W)\"\n" -" ],\n" -" [\n" -" \"42nd & Second - New York NY (W)\"\n" -" ],\n" -" [\n" -" \"1st Avenue & 75th St. - 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" -" \"150 E. 42nd Street - New York NY (W)\"\n" -" ],\n" -" [\n" -" \"Macy's 35th Street Balcony - New York NY\"\n" -" ],\n" -" [\n" -" \"Macy's 5th Floor - Herald Square - New York NY (W)\"\n" -" ],\n" -" [\n" -" \"80th & York - 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" -" \"52nd & Seventh - 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" -" \"Limited Brands-NYC - New York NY\"\n" -" ],\n" -" [\n" -" \"63rd & Broadway - New York NY (W)\"\n" -" ],\n" -" [\n" -" \"2 Columbus Ave. - New York NY (W)\"\n" -" ],\n" -" [\n" -" \"70th & Broadway - New York NY (W)\"\n" -" ],\n" -" [\n" -" \"Broadway @ 81st - New York NY (W)\"\n" -" ],\n" -" [\n" -" \"Fashion Inst of Technology - New York NY\"\n" -" ]\n" -" ]\n" -" }\n" -" }" -msgstr "" - -msgid "" -"Because the `count` says `40`, you know there are all 40 records in the table." -" Search result records are returned as an array `records`." -msgstr "`count` の値からデータが全部で 36 件あることがわかります。`records` に配列として検索結果が入っています。" - -msgid "" -"Next step, let's try more meaningful query. To search stores which contain \"Co" -"lumbus\" in their name, give `Columbus` as the parameter `query`, and give `_ke" -"y` as the parameter `match_to` which means the column to be searched. Then:" -msgstr "" -"もう少し複雑なクエリを試してみましょう。例えば、店名に「Columbus」を含む店舗を検索します。`query` パラメータにクエリ `Columbus` " -"を、`match_to` パラメータに検索対象として `_key` を指定し、以下のようなリクエストを発行します。" - -msgid "" -" # curl \"http://localhost:3000/droonga/tables/Store?query=Columbus&match_to" -"=_key&attributes=_key&limit=-1\"\n" -" {\n" -" \"result\": {\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" -" }" -msgstr "" - -msgid "As the result two stores are found by the search condition." -msgstr "以上 2 件が検索結果として該当することがわかりました。" - -msgid "### Asynchronous search request via Socket.IO" -msgstr "### Socket.IO を用いた非同期処理" - -msgid "" -"A Droonga protocol adapter supports not only REST API, but also [Socket.IO][]." -" If you send a request to a protocol adapter via Socket.IO, then the protocol " -"adapter sends back the response for the request after the operation is finishe" -"d. So you can develop a system based on a client application and an API server" -" communicating each other asynchronously." -msgstr "" -"Droonga の Protocol Adapter は、 REST API だけでなく、 [Socket.IO][] にも対応しています。Socket.I" -"O 経由で Protocol Adapter へリクエストを送ると、処理が完了した時点で Protocol Adapter から結果を送り返してもらえます。" -"この仕組を利用すると、クライアントアプリケーションと Droonga の間でリクエストとレスポンスを別々に送り合う、非同期な通信を行うことができます。" - -msgid "Now, let's create such a system based on Socket.IO." -msgstr "" -"ここでは、Webブラウザを「クライアントアプリケーション」とし、Protocol Adapter との間で Socket.IO を利用して通信するアプリケー" -"ションを作成してみましょう。" - -msgid "" -"The sample client application is a simple Web page `index.html` loaded in a We" -"b browser, returned by the protocol adapter itself.\n" -"Put a file `index.html` into the `protocol-adaptor` directory, like following:" -msgstr "" -"Protocol Adapter から `index.html` を配信し、Webブラウザに渡すことにしましょう。\n" -"`protocol-adapter` ディレクトリの下に以下の内容の `index.html` を配置します。" - -msgid "index.html:" -msgstr "" - -msgid "" -" <html>\n" -" <head>\n" -" <script src=\"/socket.io/socket.io.js\"></script>\n" -" <script>\n" -" var socket = io.connect();\n" -" socket.on('search.result', function (data) {\n" -" document.body.textContent += JSON.stringify(data);\n" -" });\n" -" socket.emit('search', { queries: {\n" -" result: {\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" -" </script>\n" -" </head>\n" -" <body>\n" -" </body>\n" -" </html>" -msgstr "" - -msgid "" -"This client sends a search query by `socket.emit()`. After the request is proc" -"essed and the result is returned, the callback given as `socket.on('search.res" -"ult', ...)` will be called with the result, and it will render the result to t" -"he page." -msgstr "" -"`socket.emit()` でクエリを送信します。クエリの処理が完了し、結果が戻ってくると、 `socket.on('search.result', ." -"..)` のコールバックが呼ばれ、ページ内にその結果が表示されます。" - -msgid "" -"The first argument `'search'` for the method call `socket.emit()` means that t" -"he request is a search request.\n" -"The second argument includes parameters of the search request. See the command" -" reference of the [`search` command](/reference/commands/search) for more deta" -"ils.\n" -"(By the way, we used a REST API to do search in the previous section. In the c" -"ase the protocol adapter translates a HTTP request to a message in the format " -"described in the [command reference of the `search`](/reference/commands/searc" -"h) internally and sends it to the Droonga engine.)" -msgstr "" -"`socket.emit()` の第1引数 `'search'` は、このリクエストが検索リクエストであることを指定しています。\n" -"第2引数でどのような検索を行うかを指定しています。\n" -"詳しくは [search](/ja/reference/commands/search) を参照してください。\n" -"ところで、前のセクションでは、REST API を利用して検索を行いました。\n" -"REST API を利用した場合は、 `express-droonga` が内部で REST リクエストから上記の形式のメッセージへと変換し、`fluent" -"-plugin-droonga` に送信するようになっています。" - -msgid "" -"Next, modify the `application.js` to host the `index.html` by the protocol ada" -"pter, like:" -msgstr "" -"では、この `index.html` を Protocol Adapter でホストできるようにするため、`application.js` を以下のように書" -"き換えます。" - -msgid "" -" //============== INSERTED ==============\n" -" application.get('/', function(req, res) {\n" -" res.sendfile(__dirname + '/index.html');\n" -" });\n" -" //============= /INSERTED ==============" -msgstr "" - -msgid "" -"Then, type the IP address of the server for experiments into the address bar o" -"f your Web browser. For example, if the IP address is `192.0.2.1`, then the lo" -"cation is `http://192.0.2.1:3000/` and you can see the contents of the `index." -"html`. When you see the search result like following, then the search request " -"is successfully processed:" -msgstr "" -"Web ブラウザにサーバの IP アドレスを入れて、リクエストを送信してみましょう。\n" -"以降、サーバの IP アドレスが `192.0.2.1` であったとします。\n" -"`http://192.0.2.1:3000/` をリクエストすると、先の `index.html` が返されるようになります。\n" -"Webブラウザから `http://192.0.2.1:3000` を開いてみてください。以下のように検索結果が表示されれば成功です。" - -msgid "" -" {\"result\":{\"count\":40,\"records\":[[\"76th & Second - New York NY (W)\"],[\"15t" -"h & Third - New York NY (W)\"],[\"41st and Broadway - New York NY (W)\"],[\"West 4" -"3rd and Broadway - New York NY (W)\"],[\"Macy's 6th Floor - Herald Square - New " -"York NY (W)\"],[\"Herald Square- Macy's - New York NY\"],[\"Columbus @ 67th - New " -"York NY (W)\"],[\"45th & Broadway - New York NY (W)\"],[\"1585 Broadway (47th) - N" -"ew York NY (W)\"],[\"85th & First - New York NY (W)\"],[\"92nd & 3rd - New York NY" -" (W)\"],[\"1656 Broadway - New York NY (W)\"],[\"19th & 8th - New York NY (W)\"],[\"" -"60th & Broadway-II - New York NY (W)\"],[\"195 Broadway - New York NY (W)\"],[\"2 " -"Broadway - New York NY (W)\"],[\"NY Plaza - New York NY (W)\"],[\"36th and Madison" -" - New York NY (W)\"],[\"125th St. btwn Adam Clayton & FDB - New York NY\"],[\"213" -"8 Broadway - New York NY (W)\"],[\"118th & Frederick Douglas Blvd. - New York NY" -" (W)\"],[\"42nd & Second - New York NY (W)\"],[\"1st Avenue & 75th St. - New York " -"NY (W)\"],[\"2nd Ave. & 9th Street - New York NY\"],[\"84th & Third Ave - New York" -" NY (W)\"],[\"150 E. 42nd Street - New York NY (W)\"],[\"Macy's 35th Street Balcon" -"y - New York NY\"],[\"Macy's 5th Floor - Herald Square - New York NY (W)\"],[\"80t" -"h & York - New York NY (W)\"],[\"Marriott Marquis - Lobby - New York NY\"],[\"Seco" -"nd @ 81st - New York NY (W)\"],[\"52nd & Seventh - New York NY (W)\"],[\"165 Broad" -"way - 1 Liberty - New York NY (W)\"],[\"54th & Broadway - New York NY (W)\"],[\"Li" -"mited Brands-NYC - New York NY\"],[\"63rd & Broadway - New York NY (W)\"],[\"2 Col" -"umbus Ave. - New York NY (W)\"],[\"70th & Broadway - New York NY (W)\"],[\"Broadwa" -"y @ 81st - New York NY (W)\"],[\"Fashion Inst of Technology - New York NY\"]]}}" -msgstr "" - -msgid "" -"Your Web browser sends a request to the protocol adapter via Socket.IO, the pr" -"otocol adapter sends it to the Droonga engine via fluent protocol, the engine " -"returns the search result to the protocol adapter, and the protocol adapter se" -"nds back the search result to the client." -msgstr "" -"Web ブラウザから Socket.IO 経由でリクエストが Protocol Adapter に送信され、それが Engine に送られ、検索結果が Pr" -"otocol Adapter に返され、さらに Web ブラウザに返されます。" - -msgid "" -"Next, try a fulltext search request like the previous section, to find stores " -"with the town name \"Columbus\".\n" -"Modify the parameter given to the `socket.emit()` method in the `index.html`, " -"like following:" -msgstr "" -"今度は全文検索を行ってみましょう。先ほどと同様に「Columbus」を店名に含む店舗を検索します。`index.html` の `socket.emit()" -"` の呼び出しを書き換え、以下の様な `index.html` を用意します。" - -msgid "" -" <html>\n" -" <head>\n" -" <script src=\"/socket.io/socket.io.js\"></script>\n" -" <script>\n" -" var socket = io.connect();\n" -" socket.on('search.result', function (data) {\n" -" document.body.textContent += JSON.stringify(data);\n" -" });\n" -" socket.emit('search', { queries: {\n" -" result: {\n" -" source: 'Store',\n" -" condition: {\n" -" query: 'Columbus',\n" -" matchTo: '_key'\n" -" },\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" -" </script>\n" -" </head>\n" -" <body>\n" -" </body>\n" -" </html>" -msgstr "" - -msgid "" -"Reload the current page `http://192.0.2.1:3000` in your Web browser, then you'" -"ll see a search result like following:" -msgstr "ブラウザで再度 `http://192.0.2.1:3000` を開くと、以下のような検索結果が表示されます。" - -msgid "" -" {\"result\":{\"count\":2,\"records\":[[\"Columbus @ 67th - New York NY (W)\"],[\"2 " -"Columbus Ave. - New York NY (W)\"]]}}" -msgstr "" - -msgid "" -"OK, you've successfully created a client application which can send search req" -"uests and receive responses asynchronously via Socket.IO." -msgstr "このように、Socket.IO を利用して、リクエストとレスポンスを非同期に送受信する検索クライアントを作成することができました。" - -msgid "## Conclusion" -msgstr "## まとめ" - -msgid "" -"In this tutorial, you did setup both packages [fluent-plugin-droonga][] and [e" -"xpress-droonga][] which construct [Droonga][] service on a [Ubuntu Linux][Ubun" -"tu].\n" -"Moreover, you built a search system based on a protocol adapter with a Droonga" -" engine, and successfully searched." -msgstr "" -"[Ubuntu Linux][Ubuntu] 上に [Droonga][] を構成するパッケージである [fluent-plugin-droonga][] " -"と [express-droonga][] をセットアップしました。\n" -"これらのパッケージを利用することで、Protocol Adapter と Droonga Engine からなるシステムを構築し、実際に検索を行いました。" - -msgid "" -" [Ubuntu]: http://www.ubuntu.com/\n" -" [Droonga]: https://droonga.org/\n" -" [fluent-plugin-droonga]: https://github.com/droonga/fluent-plugin-droonga\n" -" [express-droonga]: https://github.com/droonga/express-droonga\n" -" [Groonga]: http://groonga.org/\n" -" [Ruby]: http://www.ruby-lang.org/\n" -" [nvm]: https://github.com/creationix/nvm\n" -" [Socket.IO]: http://socket.io/\n" -" [Fluentd]: http://fluentd.org/\n" -" [Node.js]: http://nodejs.org/" -msgstr "" +msgid " * [Plugin development tutorial](plugin-development/)" +msgstr " * [プラグイン開発のチュートリアル](plugin-development/)" Copied: ja/tutorial/basic/index.md (+8 -8) 99% =================================================================== --- ja/tutorial/index.md 2014-02-07 19:30:31 +0900 (3a38522) +++ ja/tutorial/basic/index.md 2014-02-07 19:39:34 +0900 (c0f77aa) @@ -1,12 +1,12 @@ --- -title: Droonga チュートリアル +title: Droonga チュートリアル: 基本的な使い方 layout: ja --- {% comment %} ############################################## THIS FILE IS AUTOMATICALLY GENERATED FROM - "_po/ja/tutorial/index.po" + "_po/ja/tutorial/basic/index.po" DO NOT EDIT THIS FILE MANUALLY! ############################################## {% endcomment %} @@ -333,7 +333,7 @@ application.js: # curl "http://localhost:3000/droonga/tables/Store?attributes=_key&limit=-1" { - "result": { + "stores": { "count": 40, "records": [ [ @@ -466,7 +466,7 @@ application.js: # curl "http://localhost:3000/droonga/tables/Store?query=Columbus&match_to=_key&attributes=_key&limit=-1" { - "result": { + "stores": { "count": 2, "records": [ [ @@ -502,7 +502,7 @@ index.html: document.body.textContent += JSON.stringify(data); }); socket.emit('search', { queries: { - result: { + stores: { source: 'Store', output: { elements: [ @@ -566,7 +566,7 @@ Web ブラウザにサーバの IP アドレスを入れて、リクエストを `http://192.0.2.1:3000/` をリクエストすると、先の `index.html` が返されるようになります。 Webブラウザから `http://192.0.2.1:3000` を開いてみてください。以下のように検索結果が表示されれば成功です。 - {"result":{"count":40,"records":[["76th & Second - New York NY (W)"],["15th & Third - New York NY (W)"],["41st and Broadway - 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"],["Columbus @ 67th - New York NY (W)"],["45th & Broadway - New York NY (W)"],["1585 Broadway (47th) - New York NY (W)"],["85th & First - New York NY (W)"],["92nd & 3rd - New York NY (W)"],["1656 Broadway - New York NY (W)"],["19th & 8th - New York NY (W)"],["60th & Broadway-II - New York NY (W)"],["195 Broadway - New York NY (W)"],["2 Broadway - New York NY (W)"],["NY Plaza - New York NY (W)"],["36th and Madison - New York NY (W)"],["125th St. btwn Adam Clayton & FDB - New York NY"],["2138 Broadway - New York NY (W)"],["118th & Frederick Douglas Blvd. - New York NY (W)"],["42nd & Second - New York NY (W)"],["1st Avenue & 75th St. - New York NY (W)"],["2nd Ave. & 9th Street - New York NY"],["84 th & Thi rd Ave - New York NY (W)"],["150 E. 42nd Street - New York NY (W)"],["Macy's 35th Street Balcony - New York NY"],["Macy's 5th Floor - Herald Square - New York NY (W)"],["80th & York - New York NY (W)"],["Marriott Marquis - Lobby - New York NY"],["Second @ 81st - New York NY (W)"],["52nd & Seventh - New York NY (W)"],["165 Broadway - 1 Liberty - New York NY (W)"],["54th & Broadway - New York NY (W)"],["Limited Brands-NYC - New York NY"],["63rd & Broadway - New York NY (W)"],["2 Columbus Ave. - New York NY (W)"],["70th & Broadway - New York NY (W)"],["Broadway @ 81st - New York NY (W)"],["Fashion Inst of Technology - New York NY"]]}} + {"stores":{"count":40,"records":[["76th & Second - New York NY (W)"],["15th & Third - New York NY (W)"],["41st and Broadway - 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"],["Columbus @ 67th - New York NY (W)"],["45th & Broadway - New York NY (W)"],["1585 Broadway (47th) - New York NY (W)"],["85th & First - New York NY (W)"],["92nd & 3rd - New York NY (W)"],["1656 Broadway - New York NY (W)"],["19th & 8th - New York NY (W)"],["60th & Broadway-II - New York NY (W)"],["195 Broadway - New York NY (W)"],["2 Broadway - New York NY (W)"],["NY Plaza - New York NY (W)"],["36th and Madison - New York NY (W)"],["125th St. btwn Adam Clayton & FDB - New York NY"],["2138 Broadway - New York NY (W)"],["118th & Frederick Douglas Blvd. - New York NY (W)"],["42nd & Second - New York NY (W)"],["1st Avenue & 75th St. - New York NY (W)"],["2nd Ave. & 9th Street - New York NY"],["84 th & Thi rd Ave - New York NY (W)"],["150 E. 42nd Street - New York NY (W)"],["Macy's 35th Street Balcony - New York NY"],["Macy's 5th Floor - Herald Square - New York NY (W)"],["80th & York - New York NY (W)"],["Marriott Marquis - Lobby - New York NY"],["Second @ 81st - New York NY (W)"],["52nd & Seventh - New York NY (W)"],["165 Broadway - 1 Liberty - New York NY (W)"],["54th & Broadway - New York NY (W)"],["Limited Brands-NYC - New York NY"],["63rd & Broadway - New York NY (W)"],["2 Columbus Ave. - New York NY (W)"],["70th & Broadway - New York NY (W)"],["Broadway @ 81st - New York NY (W)"],["Fashion Inst of Technology - New York NY"]]}} Web ブラウザから Socket.IO 経由でリクエストが Protocol Adapter に送信され、それが Engine に送られ、検索結果が Protocol Adapter に返され、さらに Web ブラウザに返されます。 @@ -581,7 +581,7 @@ Web ブラウザから Socket.IO 経由でリクエストが Protocol Adapter document.body.textContent += JSON.stringify(data); }); socket.emit('search', { queries: { - result: { + stores: { source: 'Store', condition: { query: 'Columbus', @@ -608,7 +608,7 @@ Web ブラウザから Socket.IO 経由でリクエストが Protocol Adapter ブラウザで再度 `http://192.0.2.1:3000` を開くと、以下のような検索結果が表示されます。 - {"result":{"count":2,"records":[["Columbus @ 67th - New York NY (W)"],["2 Columbus Ave. - New York NY (W)"]]}} + {"stores":{"count":2,"records":[["Columbus @ 67th - New York NY (W)"],["2 Columbus Ave. - New York NY (W)"]]}} このように、Socket.IO を利用して、リクエストとレスポンスを非同期に送受信する検索クライアントを作成することができました。 Modified: ja/tutorial/index.md (+4 -608) =================================================================== --- ja/tutorial/index.md 2014-02-07 19:30:31 +0900 (3a38522) +++ ja/tutorial/index.md 2014-02-07 19:39:34 +0900 (f2f6871) @@ -15,616 +15,12 @@ layout: ja * TOC {:toc} -## チュートリアルのゴール +## アプリケーション開発者向け -Droonga を使った検索システムを自分で構築できるようになる。 + * [基本的な使い方のチュートリアル](basic/) -## 前提条件 +## プラグイン開発者向け -* [Ubuntu][] Server を自分でセットアップしたり、基本的な操作ができること -* [Ruby][] と [Node.js][] の基本的な知識があること + * [プラグイン開発のチュートリアル](plugin-development/) -## 概要 -### Droonga とは - -分散データ処理エンジンです。 "distributed-groonga" に由来します。 - -Droonga は複数のコンポーネントから構成されています。ユーザは、これらのパッケージを組み合わせて利用することで、全文検索をはじめとするスケーラブルな分散データ処理システムを構築することができます。 - -### Droonga を構成するコンポーネント - -#### Droonga Engine - -Droonga Engine は Droonga における分散データ処理の要となるコンポーネントです。リクエストに基いて実際のデータ処理を行います。 - -このコンポーネントは [Fluentd] のプラグインとして実装されており、 [fluent-plugin-droonga][] パッケージとして提供されます。 -[fluent-plugin-droonga][] は検索エンジンとして、オープンソースのカラムストア機能付き全文検索エンジン [Groonga][] を使用しています。 - -#### Protocol Adapter - -Protocol Adapter は、Droonga を様々なプロトコルで利用できるようにするためのアダプタです。 - -このコンポーネントは [Node.js][] のパッケージとして実装されており、[express-droonga][] パッケージとして提供されます。 - -Droonga Engine は fluentd プロトコルで通信を行います。Protocol Adapter は、ユーザがアプリケーションを構築する際に利用しやすいよう、 Droonga Engine の機能を HTTP や Socket.IO などのインタフェースで提供します。 - -## チュートリアルでつくるシステムの全体像 - -チュートリアルでは、以下の様な構成のシステムを構築します。 - - +-------------+ +------------------+ +----------------+ - | Web Browser | <--------> | Protocol Adapter | <-------> | Droonga Engine | - +-------------+ HTTP / +------------------+ Fluent +----------------+ - Socket.IO w/express-droonga protocol w/fluent-plugin - -droonga - - - \--------------------------------------------------/ - この部分を構築します - -ユーザは Protocol Adapter に、Web ブラウザなどを用いて接続します。Protocol Adapter は Droonga Engine へリクエストを送信します。実際の検索処理は Droonga Engine が行います。検索結果は、Droonga Engine から Protocol Adapter に渡され、最終的にユーザに返ります。 - -例として、[ニューヨークにあるのスターバックスの店舗](http://geocommons.com/overlays/430038)を検索できるデータベースシステムを作成することにします。 - - -## 実験用のマシンを用意する - -まずコンピュータを調達しましょう。このチュートリアルでは、既存のコンピュータにDroongaによる検索システムを構築する手順を解説します。 -以降の説明は基本的に、[DigitalOcean](https://www.digitalocean.com/)で `Ubuntu 13.10 x64` の仮想マシンのセットアップを完了し、コンソールにアクセスできる状態になった後を前提として進めます。 - -注意:Droongaが必要とするパッケージをインストールする前に、マシンが2GB以上のメモリを備えていることを確認して下さい。メモリが不足していると、ビルド時にエラーが出て、ビルドに失敗することがあります。 - -## セットアップに必要なパッケージをインストールする - -Droonga をセットアップするために必要になるパッケージをインストールします。 - - # apt-get update - # apt-get -y upgrade - # apt-get install -y ruby ruby-dev build-essential nodejs npm - -## Droonga Engine を構築する - -Droonga Engine は、データベースを保持し、実際の検索を担当する部分です。 -このセクションでは、 fluent-plugin-droonga をインストールし、検索対象となるデータを準備します。 - -### fluent-plugin-droonga をインストールする - - # gem install fluent-plugin-droonga - -Droonga Engine を構築するのに必要なパッケージがセットアップできました。引き続き設定に移ります。 - -### Droonga Engine を起動するための設定ファイルを用意する - -まず Droonga Engine 用のディレクトリを作成します。 - - # mkdir engine - # cd engine - -以下の内容で `fluentd.conf` と `catalog.json` を作成します。 - -fluentd.conf: - - <source> - type forward - port 24224 - </source> - <match starbucks.message> - name localhost:24224/starbucks - type droonga - </match> - <match output.message> - type stdout - </match> - -catalog.json: - - { - "effective_date": "2013-09-01T00:00:00Z", - "zones": ["localhost:24224/starbucks"], - "farms": { - "localhost:24224/starbucks": { - "device": ".", - "capacity": 10 - } - }, - "datasets": { - "Starbucks": { - "workers": 0, - "plugins": ["search", "groonga", "add"], - "number_of_replicas": 2, - "number_of_partitions": 2, - "partition_key": "_key", - "date_range": "infinity", - "ring": { - "localhost:23041": { - "weight": 50, - "partitions": { - "2013-09-01": [ - "localhost:24224/starbucks.000", - "localhost:24224/starbucks.001" - ] - } - }, - "localhost:23042": { - "weight": 50, - "partitions": { - "2013-09-01": [ - "localhost:24224/starbucks.002", - "localhost:24224/starbucks.003" - ] - } - } - } - } - }, - "options": { - "plugins": ["crud"] - } - } - -この `catalog.json` では、 `Starbucks` データセットを定義し、2組のレプリカ×2個のパーティションで構成するよう指示しています。 -この例では、全てのレプリカ及びパーティションは、ローカル(一つの `fluent-plugin-droonga` の管理下)に配置します。 - -`catalog.json` の詳細については [catalog.json](/ja/reference/catalog) を参照してください。 - -### fluent-plugin-droonga を起動する - -以下のようにして fluentd-plugin-droonga を起動します。 - - # fluentd --config fluentd.conf - 2013-11-12 14:14:20 +0900 [info]: starting fluentd-0.10.40 - 2013-11-12 14:14:20 +0900 [info]: reading config file path="fluentd.conf" - 2013-11-12 14:14:20 +0900 [info]: gem 'fluent-plugin-droonga' version '0.0.1' - 2013-11-12 14:14:20 +0900 [info]: gem 'fluentd' version '0.10.40' - 2013-11-12 14:14:20 +0900 [info]: using configuration file: <ROOT> - <source> - type forward - port 24224 - </source> - <match starbucks.message> - name localhost:24224/starbucks - type droonga - </match> - <match output.message> - type stdout - </match> - </ROOT> - 2013-11-12 14:14:20 +0900 [info]: adding source type="forward" - 2013-11-12 14:14:20 +0900 [info]: adding match pattern="starbucks.message" type="droonga" - 2013-11-12 14:14:20 +0900 [info]: adding match pattern="output.message" type="stdout" - 2013-11-12 14:14:20 +0900 [info]: listening fluent socket on 0.0.0.0:24224 - -### データベースを作成する - -Dronga Engine が起動したので、データを投入しましょう。 -スキーマを定義した `ddl.jsons` と、店舗のデータ `stores.jsons` を用意します。 - -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"}} - - -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"}}} - - -fluentd を起動した状態で別の端末を開き、以下のようにして `ddl.jsons` と `stores.jsons` を投入します: - - # fluent-cat starbucks.message < ddl.jsons - # fluent-cat starbucks.message < stores.jsons - - -これで、スターバックスの店舗のデータベースを検索するための Droonga Engine ができました。 -引き続き Protocol Adapter を構築して、検索リクエストを受け付けられるようにしましょう。 - - -## Protocol Adapter を構築する - -Protocol Adapter を構築するために、 `express-droonga` を使用します。 `express-droonga` は、Node.js のパッケージです。 - -### express-droonga をインストールする - - # cd ~ - # mkdir protocol-adapter - # cd protocol-adapter - -以下のような `package.json` を用意します。 - -package.json: - - { - "name": "protocol-adapter", - "description": "Droonga Protocol Adapter", - "version": "0.0.0", - "author": "Droonga Project", - "private": true, - "dependencies": { - "express": "*", - "express-droonga": "*" - } - } - -必要なパッケージをインストールします。 - - $ npm install - - -### Protocol Adapter を作成する - -以下のような内容で `application.js` を作成します。 - -application.js: - - var express = require('express'), - droonga = require('express-droonga'); - - var application = express(); - var server = require('http').createServer(application); - server.listen(3000); // the port to communicate with clients - - application.droonga({ - prefix: '/droonga', - tag: 'starbucks', - defaultDataset: 'Starbucks', - server: server, // this is required to initialize Socket.IO API! - plugins: [ - droonga.API_REST, - droonga.API_SOCKET_IO, - droonga.API_GROONGA, - droonga.API_DROONGA - ] - }); - -`application.js` を実行します。 - - # nodejs application.js - info - socket.io started - - -### HTTPでの同期的な検索のリクエスト - -準備が整いました。 Protocol Adapter に向けて HTTP 経由でリクエストを発行し、データベースに問い合わせを行ってみましょう。まずは `Shops` テーブルの中身を取得してみます。以下のようなリクエストを用います。(`attributes=_key` を指定しているのは「検索結果に `_key` 値を含めて返してほしい」という意味です。これがないと、`records` に何も値がないレコードが返ってきてしまいます。`attributes` パラメータには `,` 区切りで複数の属性を指定することができます。`attributes=_key,location` と指定することで、緯度経度もレスポンスとして受け取ることができます) - - # curl "http://localhost:3000/droonga/tables/Store?attributes=_key&limit=-1" - { - "result": { - "count": 40, - "records": [ - [ - "76th & Second - New York NY (W)" - ], - [ - "15th & Third - New York NY (W)" - ], - [ - "41st and Broadway - 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" - ], - [ - "Columbus @ 67th - New York NY (W)" - ], - [ - "45th & Broadway - New York NY (W)" - ], - [ - "1585 Broadway (47th) - New York NY (W)" - ], - [ - "85th & First - New York NY (W)" - ], - [ - "92nd & 3rd - New York NY (W)" - ], - [ - "1656 Broadway - New York NY (W)" - ], - [ - "19th & 8th - New York NY (W)" - ], - [ - "60th & Broadway-II - New York NY (W)" - ], - [ - "195 Broadway - New York NY (W)" - ], - [ - "2 Broadway - New York NY (W)" - ], - [ - "NY Plaza - New York NY (W)" - ], - [ - "36th and Madison - New York NY (W)" - ], - [ - "125th St. btwn Adam Clayton & FDB - New York NY" - ], - [ - "2138 Broadway - New York NY (W)" - ], - [ - "118th & Frederick Douglas Blvd. - New York NY (W)" - ], - [ - "42nd & Second - New York NY (W)" - ], - [ - "1st Avenue & 75th St. - New York NY (W)" - ], - [ - "2nd Ave. & 9th Street - New York NY" - ], - [ - "84th & Third Ave - New York NY (W)" - ], - [ - "150 E. 42nd Street - New York NY (W)" - ], - [ - "Macy's 35th Street Balcony - New York NY" - ], - [ - "Macy's 5th Floor - Herald Square - New York NY (W)" - ], - [ - "80th & York - New York NY (W)" - ], - [ - "Marriott Marquis - Lobby - New York NY" - ], - [ - "Second @ 81st - New York NY (W)" - ], - [ - "52nd & Seventh - New York NY (W)" - ], - [ - "165 Broadway - 1 Liberty - New York NY (W)" - ], - [ - "54th & Broadway - New York NY (W)" - ], - [ - "Limited Brands-NYC - New York NY" - ], - [ - "63rd & Broadway - New York NY (W)" - ], - [ - "2 Columbus Ave. - New York NY (W)" - ], - [ - "70th & Broadway - New York NY (W)" - ], - [ - "Broadway @ 81st - New York NY (W)" - ], - [ - "Fashion Inst of Technology - New York NY" - ] - ] - } - } - -`count` の値からデータが全部で 36 件あることがわかります。`records` に配列として検索結果が入っています。 - -もう少し複雑なクエリを試してみましょう。例えば、店名に「Columbus」を含む店舗を検索します。`query` パラメータにクエリ `Columbus` を、`match_to` パラメータに検索対象として `_key` を指定し、以下のようなリクエストを発行します。 - - # curl "http://localhost:3000/droonga/tables/Store?query=Columbus&match_to=_key&attributes=_key&limit=-1" - { - "result": { - "count": 2, - "records": [ - [ - "Columbus @ 67th - New York NY (W)" - ], - [ - "2 Columbus Ave. - New York NY (W)" - ] - ] - } - } - -以上 2 件が検索結果として該当することがわかりました。 - - -### Socket.IO を用いた非同期処理 - -Droonga の Protocol Adapter は、 REST API だけでなく、 [Socket.IO][] にも対応しています。Socket.IO 経由で Protocol Adapter へリクエストを送ると、処理が完了した時点で Protocol Adapter から結果を送り返してもらえます。この仕組を利用すると、クライアントアプリケーションと Droonga の間でリクエストとレスポンスを別々に送り合う、非同期な通信を行うことができます。 - -ここでは、Webブラウザを「クライアントアプリケーション」とし、Protocol Adapter との間で Socket.IO を利用して通信するアプリケーションを作成してみましょう。 - -Protocol Adapter から `index.html` を配信し、Webブラウザに渡すことにしましょう。 -`protocol-adapter` ディレクトリの下に以下の内容の `index.html` を配置します。 - -index.html: - - <html> - <head> - <script src="/socket.io/socket.io.js"></script> - <script> - var socket = io.connect(); - socket.on('search.result', function (data) { - document.body.textContent += JSON.stringify(data); - }); - socket.emit('search', { queries: { - result: { - source: 'Store', - output: { - elements: [ - 'startTime', - 'elapsedTime', - 'count', - 'attributes', - 'records' - ], - attributes: ['_key'], - limit: -1 - } - } - }}); - </script> - </head> - <body> - </body> - </html> - -`socket.emit()` でクエリを送信します。クエリの処理が完了し、結果が戻ってくると、 `socket.on('search.result', ...)` のコールバックが呼ばれ、ページ内にその結果が表示されます。 - -`socket.emit()` の第1引数 `'search'` は、このリクエストが検索リクエストであることを指定しています。 -第2引数でどのような検索を行うかを指定しています。 -詳しくは [search](/ja/reference/commands/search) を参照してください。 -ところで、前のセクションでは、REST API を利用して検索を行いました。 -REST API を利用した場合は、 `express-droonga` が内部で REST リクエストから上記の形式のメッセージへと変換し、`fluent-plugin-droonga` に送信するようになっています。 - -では、この `index.html` を Protocol Adapter でホストできるようにするため、`application.js` を以下のように書き換えます。 - -application.js: - - var express = require('express'), - droonga = require('express-droonga'); - - var application = express(); - var server = require('http').createServer(application); - server.listen(3000); // the port to communicate with clients - - application.droonga({ - prefix: '/droonga', - tag: 'starbucks', - defaultDataset: 'Starbucks', - server: server, // this is required to initialize Socket.IO API! - plugins: [ - droonga.API_REST, - droonga.API_SOCKET_IO, - droonga.API_GROONGA, - droonga.API_DROONGA - ] - }); - - //============== INSERTED ============== - application.get('/', function(req, res) { - res.sendfile(__dirname + '/index.html'); - }); - //============= /INSERTED ============== - -Web ブラウザにサーバの IP アドレスを入れて、リクエストを送信してみましょう。 -以降、サーバの IP アドレスが `192.0.2.1` であったとします。 -`http://192.0.2.1:3000/` をリクエストすると、先の `index.html` が返されるようになります。 -Webブラウザから `http://192.0.2.1:3000` を開いてみてください。以下のように検索結果が表示されれば成功です。 - - {"result":{"count":40,"records":[["76th & Second - New York NY (W)"],["15th & Third - New York NY (W)"],["41st and Broadway - 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"],["Columbus @ 67th - New York NY (W)"],["45th & Broadway - New York NY (W)"],["1585 Broadway (47th) - New York NY (W)"],["85th & First - New York NY (W)"],["92nd & 3rd - New York NY (W)"],["1656 Broadway - New York NY (W)"],["19th & 8th - New York NY (W)"],["60th & Broadway-II - New York NY (W)"],["195 Broadway - New York NY (W)"],["2 Broadway - New York NY (W)"],["NY Plaza - New York NY (W)"],["36th and Madison - New York NY (W)"],["125th St. btwn Adam Clayton & FDB - New York NY"],["2138 Broadway - New York NY (W)"],["118th & Frederick Douglas Blvd. - New York NY (W)"],["42nd & Second - New York NY (W)"],["1st Avenue & 75th St. - New York NY (W)"],["2nd Ave. & 9th Street - New York NY"],["84 th & Thi rd Ave - New York NY (W)"],["150 E. 42nd Street - New York NY (W)"],["Macy's 35th Street Balcony - New York NY"],["Macy's 5th Floor - Herald Square - New York NY (W)"],["80th & York - New York NY (W)"],["Marriott Marquis - Lobby - New York NY"],["Second @ 81st - New York NY (W)"],["52nd & Seventh - New York NY (W)"],["165 Broadway - 1 Liberty - New York NY (W)"],["54th & Broadway - New York NY (W)"],["Limited Brands-NYC - New York NY"],["63rd & Broadway - New York NY (W)"],["2 Columbus Ave. - New York NY (W)"],["70th & Broadway - New York NY (W)"],["Broadway @ 81st - New York NY (W)"],["Fashion Inst of Technology - New York NY"]]}} - -Web ブラウザから Socket.IO 経由でリクエストが Protocol Adapter に送信され、それが Engine に送られ、検索結果が Protocol Adapter に返され、さらに Web ブラウザに返されます。 - -今度は全文検索を行ってみましょう。先ほどと同様に「Columbus」を店名に含む店舗を検索します。`index.html` の `socket.emit()` の呼び出しを書き換え、以下の様な `index.html` を用意します。 - - <html> - <head> - <script src="/socket.io/socket.io.js"></script> - <script> - var socket = io.connect(); - socket.on('search.result', function (data) { - document.body.textContent += JSON.stringify(data); - }); - socket.emit('search', { queries: { - result: { - source: 'Store', - condition: { - query: 'Columbus', - matchTo: '_key' - }, - output: { - elements: [ - 'startTime', - 'elapsedTime', - 'count', - 'attributes', - 'records' - ], - attributes: ['_key'], - limit: -1 - } - } - }}); - </script> - </head> - <body> - </body> - </html> - -ブラウザで再度 `http://192.0.2.1:3000` を開くと、以下のような検索結果が表示されます。 - - {"result":{"count":2,"records":[["Columbus @ 67th - New York NY (W)"],["2 Columbus Ave. - New York NY (W)"]]}} - -このように、Socket.IO を利用して、リクエストとレスポンスを非同期に送受信する検索クライアントを作成することができました。 - - -## まとめ - -[Ubuntu Linux][Ubuntu] 上に [Droonga][] を構成するパッケージである [fluent-plugin-droonga][] と [express-droonga][] をセットアップしました。 -これらのパッケージを利用することで、Protocol Adapter と Droonga Engine からなるシステムを構築し、実際に検索を行いました。 - - [Ubuntu]: http://www.ubuntu.com/ - [Droonga]: https://droonga.org/ - [fluent-plugin-droonga]: https://github.com/droonga/fluent-plugin-droonga - [express-droonga]: https://github.com/droonga/express-droonga - [Groonga]: http://groonga.org/ - [Ruby]: http://www.ruby-lang.org/ - [nvm]: https://github.com/creationix/nvm - [Socket.IO]: http://socket.io/ - [Fluentd]: http://fluentd.org/ - [Node.js]: http://nodejs.org/ Modified: tutorial/index.md (+2 -2) =================================================================== --- tutorial/index.md 2014-02-07 19:30:31 +0900 (da1c6b9) +++ tutorial/index.md 2014-02-07 19:39:34 +0900 (d660fb8) @@ -6,9 +6,9 @@ layout: en * TOC {:toc} -## For application develipers +## For application developers - * [Basic tutorial](basic/) + * [Basic usage tutorial](basic/) ## For plugin developers