Skip to content

Commit

Permalink
Write about creation of original command
Browse files Browse the repository at this point in the history
  • Loading branch information
darashi committed Feb 5, 2014
1 parent 8e3a571 commit fe01991
Showing 1 changed file with 43 additions and 1 deletion.
44 changes: 43 additions & 1 deletion tutorial/plugin-development/input-output/index.md
Expand Up @@ -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
Expand Down

0 comments on commit fe01991

Please sign in to comment.