Class: Elasticity::Search::LazySearch
- Inherits:
-
Object
- Object
- Elasticity::Search::LazySearch
- Includes:
- Enumerable
- Defined in:
- lib/elasticity/search.rb
Instance Attribute Summary collapse
-
#search_definition ⇒ Object
Returns the value of attribute search_definition.
Instance Method Summary collapse
- #blank? ⇒ Boolean
- #count(args = {}) ⇒ Object
- #empty? ⇒ Boolean
-
#initialize(client, search_definition, search_args, &mapper) ⇒ LazySearch
constructor
A new instance of LazySearch.
- #search_results ⇒ Object
- #suggestions ⇒ Object
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_definition ⇒ Object
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
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
102 103 104 |
# File 'lib/elasticity/search.rb', line 102 def empty? total == 0 end |
#search_results ⇒ Object
118 119 120 |
# File 'lib/elasticity/search.rb', line 118 def search_results @search_results ||= Search::Results.new(response, @search_definition.body, @mapper) end |
#suggestions ⇒ Object
110 111 112 |
# File 'lib/elasticity/search.rb', line 110 def suggestions response["suggest"] ||= {} end |