[Groonga-commit] droonga/droonga.org at 92a7056 [gh-pages] Write about querying via REST API

Back to archive index

Yoji Shidara null+****@clear*****
Wed Aug 28 15:21:59 JST 2013


Yoji Shidara	2013-08-28 15:21:59 +0900 (Wed, 28 Aug 2013)

  New Revision: 92a7056880a44572ebb0bb13086d302daca18c62
  https://github.com/droonga/droonga.org/commit/92a7056880a44572ebb0bb13086d302daca18c62

  Message:
    Write about querying via REST API

  Modified files:
    tutorial/index.md

  Modified: tutorial/index.md (+64 -1)
===================================================================
--- tutorial/index.md    2013-08-28 14:14:44 +0900 (3803f68)
+++ tutorial/index.md    2013-08-28 15:21:59 +0900 (aa51119)
@@ -292,7 +292,70 @@ frontend.js を実行します。
 
 ### 動作を確認
 
-WIP
+準備が整いました。 frontend に向けて HTTP 経由でリクエストを発行し、データベースに問い合わせを行ってみましょう。まずは `Shops` テーブルの中身を取得してみます。以下のようなリクエストを用います。(`attributes=_key` を指定しているのは「検索結果に `_key` 値を含めて返してほしい」という意味です。これが無いと、`records` に何も値がないレコードが返ってきてしまいます。`attributes=_key,location` と指定することで、緯度経度もレスポンスとして受け取ることができます)
+
+    vagrant �� precise64:~$ curl "http://localhost:3000/droonga/tables/Shops?attributes=_key"
+    {
+      "result": {
+        "count": 36,
+        "records": [
+          [
+            "根津のたいやき"
+          ],
+          [
+            "たい焼 カタオカ"
+          ],
+          [
+            "そばたいやき空"
+          ],
+          [
+            "車"
+          ],
+          [
+            "広瀬屋"
+          ],
+          [
+            "さざれ"
+          ],
+          [
+            "おめで鯛焼き本舗錦糸町東急店"
+          ],
+          [
+            "尾長屋 錦糸町店"
+          ],
+          [
+            "たいやき工房白家 阿佐ヶ谷店"
+          ],
+          [
+            "たいやき本舗 藤家 阿佐ヶ谷店"
+          ]
+        ],
+        "startTime": "2013-08-28T06:00:13+00:00",
+        "elapsedTime": 0.0002779960632324219
+      }
+    }
+
+`count` の値からデータが全部で 36 件あることがわかります。そのうちの 10 件が取得できました。
+
+もう少し複雑なクエリを試してみましょう。例えば、店名に「阿佐ヶ谷」を含むたいやき屋を検索します。`query` パラメータにクエリ `阿佐ヶ谷` を、`match_to` パラメータに検索対象として `_key` を指定し、以下のようなリクエストを発行します。
+
+    vagrant �� precise64:~$ curl "http://localhost:3000/droonga/tables/Shops?query=%E9%98%BF%E4%BD%90%E3%83%B6%E8%B0%B7&match_to=_key&attributes=_key"
+    {
+      "result": {
+        "count": 2,
+        "records": [
+          [
+            "たいやき工房白家 阿佐ヶ谷店"
+          ],
+          [
+            "たいやき本舗 藤家 阿佐ヶ谷店"
+          ]
+        ],
+        "startTime": "2013-08-28T06:18:08+00:00",
+        "elapsedTime": 0.0005409717559814453
+      }
+
+以上 2 件が検索結果として該当することがわかりました。
 
 
   [droonga]: https://droonga.org/
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index