Class: OpenObserve::SearchResult

Inherits:
Record
  • Object
show all
Defined in:
lib/openobserve/search_result.rb

Overview

The envelope a search returns. OpenObserve does not answer with a bare array: it wraps the rows in hits alongside counters (total, took, scan sizes, trace id). Returning the envelope rather than just the rows keeps those reachable — a search that silently hit its size cap is otherwise indistinguishable from an exhaustive one.

Instance Attribute Summary

Attributes inherited from Record

#raw

Instance Method Summary collapse

Methods inherited from Record

#==, #[], from, #hash, #id, #initialize, #to_h

Constructor Details

This class inherits a constructor from OpenObserve::Record

Instance Method Details

#empty?Boolean

Returns whether the server reported no rows at all.

Returns:

  • (Boolean)

    whether the server reported no rows at all



25
26
27
# File 'lib/openobserve/search_result.rb', line 25

def empty?
  hits.empty?
end

#hitsArray<OpenObserve::Hit>

Returns the rows.

Returns:



10
11
12
# File 'lib/openobserve/search_result.rb', line 10

def hits
  @hits ||= Array(self['hits']).map { |hit| Hit.from(hit) }
end

#tookInteger?

Returns server-side duration, in milliseconds.

Returns:

  • (Integer, nil)

    server-side duration, in milliseconds



20
21
22
# File 'lib/openobserve/search_result.rb', line 20

def took
  self['took']
end

#totalInteger?

Returns total matching rows, as reported by the server.

Returns:

  • (Integer, nil)

    total matching rows, as reported by the server



15
16
17
# File 'lib/openobserve/search_result.rb', line 15

def total
  self['total']
end