YUKI Hiroshi
null+****@clear*****
Thu Nov 28 11:44:33 JST 2013
YUKI Hiroshi 2013-11-28 11:44:33 +0900 (Thu, 28 Nov 2013) New Revision: 5738ccbd73c1b8513670e85caee5f7dc6a99cbd7 https://github.com/droonga/fluent-plugin-droonga/commit/5738ccbd73c1b8513670e85caee5f7dc6a99cbd7 Message: Insert space between key and "=>" arrow Modified files: lib/droonga/plugin/distributor/search.rb Modified: lib/droonga/plugin/distributor/search.rb (+36 -20) =================================================================== --- lib/droonga/plugin/distributor/search.rb 2013-11-28 11:22:49 +0900 (ce17042) +++ lib/droonga/plugin/distributor/search.rb 2013-11-28 11:44:33 +0900 (72ba402) @@ -48,20 +48,18 @@ module Droonga } when "records" # TODO: must take "sortBy" section into account. - elements[element] = { - "type" => "sort", - "order" => ["<"], - "offset" => final_offset, - "limit" => final_limit, - } + elements[element] = sort_reducer(:attributes => query["attributes"], + :sort_keys => query["sortBy"]) + elements[element]["offset"] = final_offset + elements[element]["limit"] = final_limit end end reducer = { - "inputs"=> [input_name], - "outputs"=> [output_name], - "type"=> "reduce", - "body"=> { + "inputs" => [input_name], + "outputs" => [output_name], + "type" => "reduce", + "body" => { input_name=> { output_name=> elements, }, @@ -70,19 +68,19 @@ module Droonga message << reducer end gatherer = { - "inputs"=> output_names, - "type"=> "gather", - "body"=> name_mapper, - "post"=> true, + "inputs" => output_names, + "type" => "gather", + "body" => name_mapper, + "post" => true, } message << gatherer searcher = { - "dataset"=> envelope["dataset"] || request["dataset"], - "outputs"=> input_names, - "type"=> "broadcast", - "command"=> "search", - "replica"=> "random", - "body"=> request, + "dataset" => envelope["dataset"] || request["dataset"], + "outputs" => input_names, + "type" => "broadcast", + "command" => "search", + "replica" => "random", + "body" => request, } message.push(searcher) post(message) @@ -145,5 +143,23 @@ module Droonga [final_offset, final_limit] end + + def sort_reducer(params) + attributes = params[:attributes] + sort_keys = params[:sort_keys] + sort_keys = sort_keys["keys"] if sort_keys.is_a?(Hash) + + order = [] + unless sort_keys + order << "<" + else + sort_keys + end + + { + "type" => "sort", + "order" => order, + } + end end end -------------- next part -------------- HTML����������������������������... 下载