module Flex::Scope::VarsMethods

Public Instance Methods

facets(hash) click to toggle source
# File lib/flex/scope/vars_methods.rb, line 67
def facets(hash)
  deep_merge :facets => hash
end
fields(*value) click to toggle source

the fields that you want to retrieve (limiting the size of the response) the returned records will be frozen (for Flex::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/flex/scope/vars_methods.rb, line 24
def fields(*value)
  deep_merge :params => {:fields => array_value(value)}
end
highlight(hash) click to toggle source
# File lib/flex/scope/vars_methods.rb, line 71
def highlight(hash)
  deep_merge :highlight => hash
end
index(val) click to toggle source
# File lib/flex/scope/vars_methods.rb, line 48
def index(val)
  deep_merge :index => val
end
metrics() click to toggle source
# File lib/flex/scope/vars_methods.rb, line 75
def metrics
  deep_merge :params => {:search_type => 'count'}
end
page(value) click to toggle source

sets the :from param so it will return the nth page of size :size

# File lib/flex/scope/vars_methods.rb, line 34
def page(value)
  deep_merge :page => value || 1
end
params(value) click to toggle source

the standard :params variable

# File lib/flex/scope/vars_methods.rb, line 39
def params(value)
  deep_merge :params => value
end
query(q)
Alias for: query_string
query_string(q) click to toggle source
# File lib/flex/scope/vars_methods.rb, line 7
def query_string(q)
  hash = q.is_a?(Hash) ? q : {:query => q}
  deep_merge :cleanable_query => hash
end
Also aliased as: query
script_fields(hash) click to toggle source

script_fields(:my_field => ‘script …’, # simpler form

:my_other_field => {:script => 'script ...', ...}) # ES API
# File lib/flex/scope/vars_methods.rb, line 58
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
size(value) click to toggle source

limits the size of the retrieved hits

# File lib/flex/scope/vars_methods.rb, line 29
def size(value)
  deep_merge :params => {:size => value}
end
sort(*value) click to toggle source

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/flex/scope/vars_methods.rb, line 17
def sort(*value)
  deep_merge :sort => array_value(value)
end
type(val) click to toggle source
# File lib/flex/scope/vars_methods.rb, line 52
def type(val)
  deep_merge :type => val
end
variables(*variables) click to toggle source

meaningful alias of deep_merge

# File lib/flex/scope/vars_methods.rb, line 44
def variables(*variables)
  deep_merge *variables
end