module Elastics::Scope::VarsMethods
Public Instance Methods
the fields that you want to retrieve (limiting the size of the response) the returned records will be frozen (for Elastics::ActiveModel objects), and the missing fields will be nil pass an array eg fields.([:field_one, :field_two]) or a list of fields e.g. fields(:field_one, :field_two)
# File lib/elastics/scope/vars_methods.rb, line 24 def fields(*value) deep_merge :params => {:fields => array_value(value)} end
# File lib/elastics/scope/vars_methods.rb, line 72 def highlight(hash) deep_merge :highlight => hash end
# File lib/elastics/scope/vars_methods.rb, line 53 def index(val) deep_merge :index => val end
# File lib/elastics/scope/vars_methods.rb, line 76 def metrics deep_merge :params => {:search_type => 'count'} end
sets the :from param so it will return the nth page of size :size
# File lib/elastics/scope/vars_methods.rb, line 39 def page(value) deep_merge :page => value || 1 end
the standard :params variable
# File lib/elastics/scope/vars_methods.rb, line 44 def params(value) deep_merge :params => value end
# File lib/elastics/scope/vars_methods.rb, line 7 def query_string(q) hash = q.is_a?(Hash) ? q : {:query => q} deep_merge :cleanable_query => hash end
script_fields
(:my_field => 'script …', # simpler form
:my_other_field => {:script => 'script ...', ...}) # ES API
# File lib/elastics/scope/vars_methods.rb, line 63 def script_fields(hash) hash.keys.each do |k| v = hash[k] hash[k] = {:script => v} unless v.is_a?(Hash) hash[k][:script].gsub!(/\n+\s*/,' ') end deep_merge :script_fields => hash end
limits the size of the retrieved hits
# File lib/elastics/scope/vars_methods.rb, line 34 def size(value) deep_merge :params => {:size => value} end
accepts one or an array or a list of sort structures documented at www.elasticsearch.org/guide/reference/api/search/sort.html doesn't probably support the multiple hash form, but you can pass an hash as single argument or an array or list of hashes
# File lib/elastics/scope/vars_methods.rb, line 17 def sort(*value) deep_merge :sort => array_value(value) end
# File lib/elastics/scope/vars_methods.rb, line 28 def source(*value) deep_merge :params => {:_source => array_value(value)} end
# File lib/elastics/scope/vars_methods.rb, line 57 def type(val) deep_merge :type => val end
meaningful alias of deep_merge
# File lib/elastics/scope/vars_methods.rb, line 49 def variables(*variables) deep_merge *variables end