Yoji Shidara
null+****@clear*****
Mon Jan 27 12:46:52 JST 2014
Yoji Shidara 2014-01-27 12:46:52 +0900 (Mon, 27 Jan 2014) New Revision: dcb98c5f6ccdbe543d52ead16563d48130feee54 https://github.com/droonga/fluent-plugin-droonga/commit/dcb98c5f6ccdbe543d52ead16563d48130feee54 Message: search: include attribute name at least for expr Specification for expression can not decided in a straightforward way because their values can be in multiple types. This commit aims to be same form as ordinal attributes in the sense that both are in hash and have "name". Modified files: lib/droonga/searcher.rb test/unit/plugin/handler/test_search.rb Modified: lib/droonga/searcher.rb (+9 -1) =================================================================== --- lib/droonga/searcher.rb 2014-01-27 12:06:42 +0900 (37d78cf) +++ lib/droonga/searcher.rb 2014-01-27 12:46:52 +0900 (e63d8b9) @@ -373,7 +373,7 @@ module Droonga else expression = attribute[:expression] if expression - # TODO implement + format_attribute_expression(label, expression) else column = table.column(source) format_attribute_column(label, column) @@ -397,6 +397,10 @@ module Droonga {"name" => label, "type" => column.range.name, "vector" => vector} end + def format_attribute_expression(label, expression) + {"name" => label} # TODO include detailed information of expression + end + def format_attributes(attributes, table) attributes.collect do |attribute| format_attribute(attribute, table) @@ -418,6 +422,10 @@ module Droonga {"type" => column.range.name, "vector" => vector} end + def format_attribute_expression(label, expression) + {} # TODO include detailed information of expression + end + def format_attributes(attributes, table) formatted_attributes = {} attributes.each do |attribute| Modified: test/unit/plugin/handler/test_search.rb (+59 -0) =================================================================== --- test/unit/plugin/handler/test_search.rb 2014-01-27 12:06:42 +0900 (5875075) +++ test/unit/plugin/handler/test_search.rb 2014-01-27 12:46:52 +0900 (559208f) @@ -297,6 +297,65 @@ class SearchHandlerTest < Test::Unit::TestCase }) end + def test_attributes_expression_simple + assert_search({ + "sections-result" => { + "attributes" => [ + { + "name" => "text", # TODO include some information + }, + ] + }, + }, + { + "queries" => { + "sections-result" => { + "source" => "Sections", + "output" => { + "elements" => [ + "attributes" + ], + "attributes" => [ + { + "label" => "text", + "source" => "'hello'", + }, + ], + }, + }, + }, + }) + end + + def test_attributes_expression_complex + assert_search({ + "sections-result" => { + "attributes" => { + "text" => {} # TODO include some information + }, + }, + }, + { + "queries" => { + "sections-result" => { + "source" => "Sections", + "output" => { + "format" => "complex", + "elements" => [ + "attributes" + ], + "attributes" => [ + { + "label" => "text", + "source" => "'hello'", + }, + ], + }, + }, + }, + }) + end + def test_attributes_subrecs_simple assert_search({ "sections-result" => { -------------- next part -------------- HTML����������������������������...Descargar