Kouhei Sutou
null+****@clear*****
Mon Jan 20 19:29:23 JST 2014
Kouhei Sutou 2014-01-20 19:29:23 +0900 (Mon, 20 Jan 2014) New Revision: 3006d2a8c4cd203d0532cd0294a5e09384a307a2 https://github.com/droonga/fluent-plugin-droonga/commit/3006d2a8c4cd203d0532cd0294a5e09384a307a2 Message: search: implement sub records output in simple mode Modified files: lib/droonga/searcher.rb test/unit/plugin/handler/test_search.rb Modified: lib/droonga/searcher.rb (+18 -7) =================================================================== --- lib/droonga/searcher.rb 2014-01-20 18:33:55 +0900 (068e8f7) +++ lib/droonga/searcher.rb 2014-01-20 19:29:23 +0900 (3c5f482) @@ -434,31 +434,38 @@ module Droonga def format_attributes_simple(attributes) attributes.collect do |attribute| - format_attribute(attribute) + format_attribute(attribute, @result.records) end end def format_attributes_complex(attributes) formatted_attributes = {} attributes.collect do |attribute| - formatted_attribute = format_attribute(attribute) + formatted_attribute = format_attribute(attribute, @result.records) attribute_name = formatted_attribute.delete("name") formatted_attributes[attribute_name] = formatted_attribute end formatted_attributes end - def format_attribute(attribute) + def format_attribute(attribute, table) label = attribute[:label] source = attribute[:source] if source == "_subrecs" - # TODO implement + sub_record_table = table.range + sub_attributes = attribute[:attributes].collect do |sub_attribute| + format_attribute(sub_attribute, sub_record_table) + end + { + "name" => label, + "attributes" => sub_attributes, + } else expression = attribute[:expression] if expression # TODO implement else - column =****@resul*****(source) + column = table.column(source) vector = column.respond_to?(:vector?) ? column.vector? : false {"name" => label, "type" => column.range.name, "vector" => vector} end @@ -558,13 +565,17 @@ module Droonga condition.value =****@resul***** source = nil end - { + normalized_attributes = { label: attribute["label"] || attribute["source"], source: source, expression: expression, variable: variable, - attributes: attribute["attributes"] } + if attribute["attributes"] + normalized_attributes[:attributes] = + normalize_target_attributes(attribute["attributes"], domain.range) + end + normalized_attributes end end Modified: test/unit/plugin/handler/test_search.rb (+5 -1) =================================================================== --- test/unit/plugin/handler/test_search.rb 2014-01-20 18:33:55 +0900 (e56ab67) +++ test/unit/plugin/handler/test_search.rb 2014-01-20 19:29:23 +0900 (aa5ff1f) @@ -298,7 +298,6 @@ class SearchHandlerTest < Test::Unit::TestCase end def test_attributes_subrecs_simple - pend "Not implemented yet" assert_search({ "sections-result" => { "attributes" => [ @@ -321,6 +320,11 @@ class SearchHandlerTest < Test::Unit::TestCase "name" => "subrecs", "attributes" => [ { + "name" => "_key", + "type" => "ShortText", + "vector" => false + }, + { "name" => "sectionTitle", "type" => "ShortText", "vector" => false -------------- next part -------------- HTML����������������������������...Download