Added support for partial_fields #434

Closed
wants to merge 1 commit into from
+9 −0
View
9 lib/tire/search.rb
@@ -116,6 +116,14 @@ def version(value)
self
end
+ def partial_fields(name, include_fields, exclude_fields =[])
+ @partial_fields ||= {}
+ @partial_fields[name] = {}
+ @partial_fields[name]['include'] = include_fields unless include_fields.empty?
+ @partial_fields[name]['exclude'] = exclude_fields unless exclude_fields.empty?
+ self
+ end
+
def perform
@response = Configuration.client.get(self.url + self.params, self.to_json)
if @response.failure?
@@ -149,6 +157,7 @@ def to_hash
request.update( { :script_fields => @script_fields } ) if @script_fields
request.update( { :version => @version } ) if @version
request.update( { :explain => @explain } ) if @explain
+ request.update( { :partial_fields => @partial_fields} ) if @partial_fields
request
end
end