Class: Elasticity::Search::LazySearch

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/elasticity/search.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client, search_definition, search_args, &mapper) ⇒ LazySearch

Returns a new instance of LazySearch.



95
96
97
98
99
100
# 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

Instance Attribute Details

#search_definitionObject

Returns the value of attribute search_definition.



93
94
95
# File 'lib/elasticity/search.rb', line 93

def search_definition
  @search_definition
end

Instance Method Details

#blank?Boolean

Returns:

  • (Boolean)


106
107
108
# File 'lib/elasticity/search.rb', line 106

def blank?
  empty?
end

#count(args = {}) ⇒ Object



114
115
116
# File 'lib/elasticity/search.rb', line 114

def count(args = {})
  @client.count(@search_definition.to_count_args.reverse_merge(args))["count"]
end

#empty?Boolean

Returns:

  • (Boolean)


102
103
104
# File 'lib/elasticity/search.rb', line 102

def empty?
  total == 0
end

#search_resultsObject



118
119
120
# File 'lib/elasticity/search.rb', line 118

def search_results
  @search_results ||= Search::Results.new(response, @search_definition.body, @mapper)
end

#suggestionsObject



110
111
112
# File 'lib/elasticity/search.rb', line 110

def suggestions
  response["suggest"] ||= {}
end