Class: ElasticSearchFacetScanner
- Inherits:
-
Object
- Object
- ElasticSearchFacetScanner
- Includes:
- Enumerable
- Defined in:
- lib/elasticsearch_facet_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
- #has_more? ⇒ Boolean
-
#initialize(url, field, size = 100, max_retries = 5) ⇒ ElasticSearchFacetScanner
constructor
A new instance of ElasticSearchFacetScanner.
Constructor Details
#initialize(url, field, size = 100, max_retries = 5) ⇒ ElasticSearchFacetScanner
Returns a new instance of ElasticSearchFacetScanner.
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/elasticsearch_facet_scanner.rb', line 11 def initialize(url, field, size=100, max_retries = 5) @url = url @field = field @aggregation_name = "#{field}_terms" @size = size @max_retries = max_retries @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_facet_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_facet_scanner.rb', line 8 def total_request_time @total_request_time end |
Instance Method Details
#each ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/elasticsearch_facet_scanner.rb', line 32 def each each_batch do |results| results.each do |result| yield result end end end |
#each_batch {|search| ... } ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/elasticsearch_facet_scanner.rb', line 22 def each_batch yield search while has_more? yield search end nil end |
#has_more? ⇒ Boolean
40 41 42 |
# File 'lib/elasticsearch_facet_scanner.rb', line 40 def has_more? @has_more end |