class Elasticity::Search::LazySearch

Attributes

search_definition[RW]

Public Class Methods

new(client, search_definition, search_args, &mapper) click to toggle source
# File lib/elasticity/search.rb, line 95
def initialize(client, search_definition, search_args, &mapper)
  @client            = client
  @search_definition = search_definition
  @mapper            = mapper
  @search_args       = search_args
end

Public Instance Methods

blank?() click to toggle source
# File lib/elasticity/search.rb, line 106
def blank?
  empty?
end
count(args = {}) click to toggle source
# File lib/elasticity/search.rb, line 114
def count(args = {})
  @client.count(@search_definition.to_count_args.reverse_merge(args))["count"]
end
empty?() click to toggle source
# File lib/elasticity/search.rb, line 102
def empty?
  total == 0
end
search_results() click to toggle source
# File lib/elasticity/search.rb, line 118
def search_results
  @search_results ||= Search::Results.new(response, @search_definition.body, @mapper)
end
suggestions() click to toggle source
# File lib/elasticity/search.rb, line 110
def suggestions
  response["suggest"] ||= {}
end

Private Instance Methods

response() click to toggle source
# File lib/elasticity/search.rb, line 124
def response
  return @response if defined?(@response)
  @response = @client.search(@search_definition.to_search_args.reverse_merge(@search_args))
end