Class: OpenObserve::SearchResult
- 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
Instance Method Summary collapse
-
#empty? ⇒ Boolean
Whether the server reported no rows at all.
-
#hits ⇒ Array<OpenObserve::Hit>
The rows.
-
#took ⇒ Integer?
Server-side duration, in milliseconds.
-
#total ⇒ Integer?
Total matching rows, as reported by the server.
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.
25 26 27 |
# File 'lib/openobserve/search_result.rb', line 25 def empty? hits.empty? end |
#hits ⇒ Array<OpenObserve::Hit>
Returns the rows.
10 11 12 |
# File 'lib/openobserve/search_result.rb', line 10 def hits @hits ||= Array(self['hits']).map { |hit| Hit.from(hit) } end |
#took ⇒ Integer?
Returns server-side duration, in milliseconds.
20 21 22 |
# File 'lib/openobserve/search_result.rb', line 20 def took self['took'] end |
#total ⇒ Integer?
Returns total matching rows, as reported by the server.
15 16 17 |
# File 'lib/openobserve/search_result.rb', line 15 def total self['total'] end |