[Groonga-commit] droonga/droonga.org at fe01991 [gh-pages] Write about creation of original command

Back to archive index

Yoji Shidara null+****@clear*****
Wed Feb 5 19:02:28 JST 2014


Yoji Shidara	2014-02-05 19:02:28 +0900 (Wed, 05 Feb 2014)

  New Revision: fe01991b78154b9bfb810b3a75371abf63b8a73a
  https://github.com/droonga/droonga.org/commit/fe01991b78154b9bfb810b3a75371abf63b8a73a

  Message:
    Write about creation of original command

  Modified files:
    tutorial/plugin-development/input-output/index.md

  Modified: tutorial/plugin-development/input-output/index.md (+43 -1)
===================================================================
--- tutorial/plugin-development/input-output/index.md    2014-02-05 19:06:04 +0900 (2b524cd)
+++ tutorial/plugin-development/input-output/index.md    2014-02-05 19:02:28 +0900 (b0d25f7)
@@ -217,7 +217,49 @@ Note that `count` is still `2` because `limit` does not affect `count`. See [sea
 
 ### Defining original command
 
-TODO: write steps to create a new command "starbucks" and accept simple query
+You may feel the Droonga's `search` command is too flexible for your purpose. Here, we're going to add our own `storeSearch` command to wrap the `search` command in order to provide an application-specific and simple interface.
+
+~~~
+module Droonga
+  class ExampleInputAdapterPlugin < Droonga::InputAdapterPlugin
+    repository.register("example", self)
+
+    command "storeSearch" => :adapt_request
+    def adapt_request(input_message)
+      $log.info "ExampleInputAdapterPlugin", message: input_message
+
+      query = input_message.body["query"]
+      body = {
+        "queries" => {
+          "result" => {
+            "source" => "Store",
+            "condition" => {
+              "query" => query,
+              "matchTo" => "_key"
+            },
+            "output" => {
+              "elements" => [
+                "startTime",
+                "elapsedTime",
+                "count",
+                "attributes",
+                "records"
+              ],
+              "attributes" => [
+                "_key"
+              ],
+              "limit" => -1
+            }
+          }
+        }
+      }
+
+      input_message.command = "search"
+      input_message.body = body
+    end
+  end
+end
+~~~
 
 
 ## OutputAdapter
-------------- next part --------------
HTML����������������������������...
Download 



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