Class: Lstash::Client
- Inherits:
-
Object
- Object
- Lstash::Client
- Defined in:
- lib/lstash/client.rb
Defined Under Namespace
Classes: ConnectionError
Constant Summary collapse
- PER_PAGE =
best time, lowest resource usage
5000.freeze
Instance Method Summary collapse
- #count(query) ⇒ Object
- #grep(query) ⇒ Object
-
#initialize(es_client, options = {}) ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize(es_client, options = {}) ⇒ Client
Returns a new instance of Client.
18 19 20 21 22 23 |
# File 'lib/lstash/client.rb', line 18 def initialize(es_client, = {}) raise ConnectionError, "No elasticsearch client specified" if es_client.nil? @es_client = es_client @logger = [:logger] || ([:debug] ? debug_logger : NullLogger.new) end |
Instance Method Details
#count(query) ⇒ Object
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/lstash/client.rb', line 25 def count(query) @logger.debug "count from=#{query.from} to=#{query.to}" count = 0 query.each_hour do |index, hour_query| count += (index, hour_query) end @logger.debug "total count=#{count}" count end |
#grep(query) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/lstash/client.rb', line 36 def grep(query) @logger.debug "grep from=#{query.from} to=#{query.to}" count = 0 query.each_hour do |index, hour_query| (index, hour_query) do || count += 1 yield if block_given? end end @logger.debug "total count=#{count}" count end |