Permalink
Browse files

[#472] Added support for loading partial fields

  • Loading branch information...
1 parent 7d834af commit 1c16b6860a78d187bc78591ea1533ed4d9693531 @uriagassi uriagassi committed with Oct 9, 2012
Showing with 19 additions and 0 deletions.
  1. +6 −0 lib/tire/search.rb
  2. +13 −0 test/unit/search_test.rb
View
@@ -105,6 +105,11 @@ def fields(*fields)
@fields = Array(fields.flatten)
self
end
+
+ def partial_field(name, options)
+ @partial_fields ||= {}
+ @partial_fields[name] = options
+ end
def explain(value)
@explain = value
@@ -156,6 +161,7 @@ def to_hash
request.update( { :size => @size } ) if @size
request.update( { :from => @from } ) if @from
request.update( { :fields => @fields } ) if @fields
+ request.update( { :partial_fields => @partial_fields } ) if @partial_fields
request.update( { :script_fields => @script_fields } ) if @script_fields
request.update( { :version => @version } ) if @version
request.update( { :explain => @explain } ) if @explain
View
@@ -414,6 +414,19 @@ def foo; 'bar'; end
end
end
+ context "with partial fields" do
+
+ should "add partial_fields config" do
+ s = Search::Search.new('index') do
+ partial_field 'name', :include => 'name_*'
+ end
+
+ hash = MultiJson.decode( s.to_json )
+ assert_equal({'name' => { 'include' => 'name_*'} }, hash['partial_fields'])
+ end
+
+ end
+
context "explain" do
should "default to false" do

0 comments on commit 1c16b68

Please sign in to comment.