Class: LogStash::Search::Result

Inherits:
Object
  • Object
show all
Defined in:
lib/logstash/search/result.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(settings = {}) ⇒ Result

Returns a new instance of Result.



20
21
22
23
24
# File 'lib/logstash/search/result.rb', line 20

def initialize(settings={})
  @events = []
  @duration = nil
  @error_message = nil
end

Instance Attribute Details

#durationObject

How long this query took, in seconds (or fractions of).



9
10
11
# File 'lib/logstash/search/result.rb', line 9

def duration
  @duration
end

#error_messageObject

Error message, if any.



18
19
20
# File 'lib/logstash/search/result.rb', line 18

def error_message
  @error_message
end

#eventsObject

Array of LogStash::Event of results



6
7
8
# File 'lib/logstash/search/result.rb', line 6

def events
  @events
end

#offsetObject

Offset in search



12
13
14
# File 'lib/logstash/search/result.rb', line 12

def offset
  @offset
end

#totalObject

Total records matched by this query, regardless of offset/count in query.



15
16
17
# File 'lib/logstash/search/result.rb', line 15

def total
  @total
end

Instance Method Details

#error?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/logstash/search/result.rb', line 26

def error?
  return !@error_message.nil?
end

#to_jsonObject



30
31
32
33
34
35
36
37
# File 'lib/logstash/search/result.rb', line 30

def to_json
  return {
    "events" => @events,
    "duration" => @duration,
    "offset" => @offset,
    "total" => @total,
  }.to_json
end