Class: Redis::Commands::Search::HybridResult
- Inherits:
-
Object
- Object
- Redis::Commands::Search::HybridResult
- Includes:
- Enumerable
- Defined in:
- lib/redis/commands/modules/search/result.rb
Overview
Result of FT.HYBRID: the fused result rows (each a field => value hash, including the
synthetic "__key" and "__score") plus the total, any warnings and the execution time.
When the query used WITHCURSOR the server returns per-leg cursor ids instead of an inline page; those are exposed via #search_cursor / #vsim_cursor and #cursor? is true.
Instance Attribute Summary collapse
- #execution_time ⇒ Array<Hash{String => Object}>, ... readonly
- #rows ⇒ Array<Hash{String => Object}>, ... readonly
- #search_cursor ⇒ Array<Hash{String => Object}>, ... readonly
- #total ⇒ Array<Hash{String => Object}>, ... readonly
- #vsim_cursor ⇒ Array<Hash{String => Object}>, ... readonly
- #warnings ⇒ Array<Hash{String => Object}>, ... readonly
Instance Method Summary collapse
-
#[](index) ⇒ Hash?
The row at
index, or nil when out of range. -
#cursor? ⇒ Boolean
Whether this is a WITHCURSOR reply carrying cursor ids.
-
#each {|row| ... } ⇒ Enumerator, Array<Hash>
Iterate over the result rows.
-
#empty? ⇒ Boolean
Whether there are no rows.
-
#initialize(rows: [], total: nil, warnings: [], execution_time: nil, search_cursor: nil, vsim_cursor: nil) ⇒ HybridResult
constructor
A new instance of HybridResult.
-
#size ⇒ Integer
(also: #length)
The number of rows.
Constructor Details
#initialize(rows: [], total: nil, warnings: [], execution_time: nil, search_cursor: nil, vsim_cursor: nil) ⇒ HybridResult
Returns a new instance of HybridResult.
177 178 179 180 181 182 183 184 185 |
# File 'lib/redis/commands/modules/search/result.rb', line 177 def initialize(rows: [], total: nil, warnings: [], execution_time: nil, search_cursor: nil, vsim_cursor: nil) @rows = rows @total = total @warnings = warnings @execution_time = execution_time @search_cursor = search_cursor @vsim_cursor = vsim_cursor end |
Instance Attribute Details
#execution_time ⇒ Array<Hash{String => Object}>, ... (readonly)
175 176 177 |
# File 'lib/redis/commands/modules/search/result.rb', line 175 def execution_time @execution_time end |
#rows ⇒ Array<Hash{String => Object}>, ... (readonly)
175 176 177 |
# File 'lib/redis/commands/modules/search/result.rb', line 175 def rows @rows end |
#search_cursor ⇒ Array<Hash{String => Object}>, ... (readonly)
175 176 177 |
# File 'lib/redis/commands/modules/search/result.rb', line 175 def search_cursor @search_cursor end |
#total ⇒ Array<Hash{String => Object}>, ... (readonly)
175 176 177 |
# File 'lib/redis/commands/modules/search/result.rb', line 175 def total @total end |
#vsim_cursor ⇒ Array<Hash{String => Object}>, ... (readonly)
175 176 177 |
# File 'lib/redis/commands/modules/search/result.rb', line 175 def vsim_cursor @vsim_cursor end |
#warnings ⇒ Array<Hash{String => Object}>, ... (readonly)
175 176 177 |
# File 'lib/redis/commands/modules/search/result.rb', line 175 def warnings @warnings end |
Instance Method Details
#[](index) ⇒ Hash?
Returns the row at index, or nil when out of range.
197 198 199 |
# File 'lib/redis/commands/modules/search/result.rb', line 197 def [](index) @rows[index] end |
#cursor? ⇒ Boolean
Returns whether this is a WITHCURSOR reply carrying cursor ids.
213 214 215 |
# File 'lib/redis/commands/modules/search/result.rb', line 213 def cursor? !@search_cursor.nil? || !@vsim_cursor.nil? end |
#each {|row| ... } ⇒ Enumerator, Array<Hash>
Iterate over the result rows.
191 192 193 |
# File 'lib/redis/commands/modules/search/result.rb', line 191 def each(&block) @rows.each(&block) end |
#empty? ⇒ Boolean
Returns whether there are no rows.
208 209 210 |
# File 'lib/redis/commands/modules/search/result.rb', line 208 def empty? @rows.empty? end |
#size ⇒ Integer Also known as: length
Returns the number of rows.
202 203 204 |
# File 'lib/redis/commands/modules/search/result.rb', line 202 def size @rows.size end |