Class: ElasticSearchScanner
- Inherits:
-
Object
- Object
- ElasticSearchScanner
- Includes:
- Enumerable
- Defined in:
- lib/elasticsearch_scanner.rb
Constant Summary collapse
- SCROLL_PATH =
'/_search/scroll'
Instance Attribute Summary collapse
-
#total_elasticsearch_time ⇒ Object
readonly
Returns the value of attribute total_elasticsearch_time.
-
#total_request_time ⇒ Object
readonly
Returns the value of attribute total_request_time.
Instance Method Summary collapse
- #each ⇒ Object
- #each_batch {|search| ... } ⇒ Object
- #fields_to_return=(fields_to_return) ⇒ Object
- #has_more? ⇒ Boolean
-
#initialize(url, query, size = 100, scroll_ttl = '1m', max_retries = 5) ⇒ ElasticSearchScanner
constructor
A new instance of ElasticSearchScanner.
Constructor Details
#initialize(url, query, size = 100, scroll_ttl = '1m', max_retries = 5) ⇒ ElasticSearchScanner
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/elasticsearch_scanner.rb', line 11 def initialize(url, query, size=100, scroll_ttl = '1m', max_retries = 5) @url = url @query = query @size = size @scroll_ttl = scroll_ttl @max_retries = max_retries @fields_to_return = true # all fields @has_more = true @total_request_time = 0.0 @total_elasticsearch_time = 0.0 end |
Instance Attribute Details
#total_elasticsearch_time ⇒ Object (readonly)
Returns the value of attribute total_elasticsearch_time.
8 9 10 |
# File 'lib/elasticsearch_scanner.rb', line 8 def total_elasticsearch_time @total_elasticsearch_time end |
#total_request_time ⇒ Object (readonly)
Returns the value of attribute total_request_time.
8 9 10 |
# File 'lib/elasticsearch_scanner.rb', line 8 def total_request_time @total_request_time end |
Instance Method Details
#each ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/elasticsearch_scanner.rb', line 37 def each each_batch do |results| results.each do |result| yield result end end end |
#each_batch {|search| ... } ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'lib/elasticsearch_scanner.rb', line 27 def each_batch yield search while has_more? yield scroll end nil end |
#fields_to_return=(fields_to_return) ⇒ Object
23 24 25 |
# File 'lib/elasticsearch_scanner.rb', line 23 def fields_to_return=(fields_to_return) @fields_to_return = fields_to_return end |
#has_more? ⇒ Boolean
45 46 47 |
# File 'lib/elasticsearch_scanner.rb', line 45 def has_more? @has_more end |