Class: Elasticity::Search::ScanCursor
- Inherits:
-
Object
- Object
- Elasticity::Search::ScanCursor
- Includes:
- Enumerable
- Defined in:
- lib/elasticity/search.rb
Instance Method Summary collapse
- #blank? ⇒ Boolean
- #each ⇒ Object
- #each_batch ⇒ Object
- #empty? ⇒ Boolean
-
#initialize(client, search_definition, mapper, size: 100, scroll: "1m") ⇒ ScanCursor
constructor
A new instance of ScanCursor.
- #total ⇒ Object
Constructor Details
#initialize(client, search_definition, mapper, size: 100, scroll: "1m") ⇒ ScanCursor
Returns a new instance of ScanCursor.
133 134 135 136 137 138 139 |
# File 'lib/elasticity/search.rb', line 133 def initialize(client, search_definition, mapper, size: 100, scroll: "1m") @client = client @search_definition = search_definition @mapper = mapper @size = size @scroll = scroll end |
Instance Method Details
#blank? ⇒ Boolean
145 146 147 |
# File 'lib/elasticity/search.rb', line 145 def blank? empty? end |
#each ⇒ Object
164 165 166 167 168 |
# File 'lib/elasticity/search.rb', line 164 def each enumerator.each do |group| group.each { |doc| yield(doc) } end end |
#each_batch ⇒ Object
158 159 160 161 162 |
# File 'lib/elasticity/search.rb', line 158 def each_batch enumerator.each do |group| yield(group) end end |
#empty? ⇒ Boolean
141 142 143 |
# File 'lib/elasticity/search.rb', line 141 def empty? total == 0 end |
#total ⇒ Object
149 150 151 152 153 154 155 156 |
# File 'lib/elasticity/search.rb', line 149 def total res = search["hits"]["total"] if res.is_a?(::Hash) res["value"] else res end end |