123456789_123456789_123456789_123456789_123456789_

Class: Redis::Commands::Search::HybridResult

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Instance Chain:
self, Enumerable
Inherits: Object
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.

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.new(rows: [], total: nil, warnings: [], execution_time: nil, search_cursor: nil, vsim_cursor: nil) ⇒ HybridResult

[ GitHub ]

  
# 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

#cursor?Boolean (readonly)

Returns:

  • (Boolean)

    whether this is a WITHCURSOR reply carrying cursor ids

[ GitHub ]

  
# File 'lib/redis/commands/modules/search/result.rb', line 213

def cursor?
  !@search_cursor.nil? || !@vsim_cursor.nil?
end

#empty?Boolean (readonly)

Returns:

  • (Boolean)

    whether there are no rows

[ GitHub ]

  
# File 'lib/redis/commands/modules/search/result.rb', line 208

def empty?
  @rows.empty?
end

#execution_timeArray<Hash{String => Object}>, ... (readonly)

Returns:

  • (Array<Hash{String => Object}>)

    the fused result rows

  • (Integer, nil)

    the total number of fused results

  • (Array)

    any warnings returned by the server

  • (Float, nil)

    the server-side execution time

  • (Integer, nil)

    the SEARCH-leg cursor id (WITHCURSOR only)

  • (Integer, nil)

    the VSIM-leg cursor id (WITHCURSOR only)

[ GitHub ]

  
# File 'lib/redis/commands/modules/search/result.rb', line 175

attr_reader :rows, :total, :warnings, :execution_time, :search_cursor, :vsim_cursor

#rowsArray<Hash{String => Object}>, ... (readonly)

Returns:

  • (Array<Hash{String => Object}>)

    the fused result rows

  • (Integer, nil)

    the total number of fused results

  • (Array)

    any warnings returned by the server

  • (Float, nil)

    the server-side execution time

  • (Integer, nil)

    the SEARCH-leg cursor id (WITHCURSOR only)

  • (Integer, nil)

    the VSIM-leg cursor id (WITHCURSOR only)

[ GitHub ]

  
# File 'lib/redis/commands/modules/search/result.rb', line 175

attr_reader :rows, :total, :warnings, :execution_time, :search_cursor, :vsim_cursor

#search_cursorArray<Hash{String => Object}>, ... (readonly)

Returns:

  • (Array<Hash{String => Object}>)

    the fused result rows

  • (Integer, nil)

    the total number of fused results

  • (Array)

    any warnings returned by the server

  • (Float, nil)

    the server-side execution time

  • (Integer, nil)

    the SEARCH-leg cursor id (WITHCURSOR only)

  • (Integer, nil)

    the VSIM-leg cursor id (WITHCURSOR only)

[ GitHub ]

  
# File 'lib/redis/commands/modules/search/result.rb', line 175

attr_reader :rows, :total, :warnings, :execution_time, :search_cursor, :vsim_cursor

#totalArray<Hash{String => Object}>, ... (readonly)

Returns:

  • (Array<Hash{String => Object}>)

    the fused result rows

  • (Integer, nil)

    the total number of fused results

  • (Array)

    any warnings returned by the server

  • (Float, nil)

    the server-side execution time

  • (Integer, nil)

    the SEARCH-leg cursor id (WITHCURSOR only)

  • (Integer, nil)

    the VSIM-leg cursor id (WITHCURSOR only)

[ GitHub ]

  
# File 'lib/redis/commands/modules/search/result.rb', line 175

attr_reader :rows, :total, :warnings, :execution_time, :search_cursor, :vsim_cursor

#vsim_cursorArray<Hash{String => Object}>, ... (readonly)

Returns:

  • (Array<Hash{String => Object}>)

    the fused result rows

  • (Integer, nil)

    the total number of fused results

  • (Array)

    any warnings returned by the server

  • (Float, nil)

    the server-side execution time

  • (Integer, nil)

    the SEARCH-leg cursor id (WITHCURSOR only)

  • (Integer, nil)

    the VSIM-leg cursor id (WITHCURSOR only)

[ GitHub ]

  
# File 'lib/redis/commands/modules/search/result.rb', line 175

attr_reader :rows, :total, :warnings, :execution_time, :search_cursor, :vsim_cursor

#warningsArray<Hash{String => Object}>, ... (readonly)

Returns:

  • (Array<Hash{String => Object}>)

    the fused result rows

  • (Integer, nil)

    the total number of fused results

  • (Array)

    any warnings returned by the server

  • (Float, nil)

    the server-side execution time

  • (Integer, nil)

    the SEARCH-leg cursor id (WITHCURSOR only)

  • (Integer, nil)

    the VSIM-leg cursor id (WITHCURSOR only)

[ GitHub ]

  
# File 'lib/redis/commands/modules/search/result.rb', line 175

attr_reader :rows, :total, :warnings, :execution_time, :search_cursor, :vsim_cursor

Instance Method Details

#[](index) ⇒ Hash?

Parameters:

  • index (Integer)

    the row position

Returns:

  • (Hash, nil)

    the row at index, or nil when out of range

[ GitHub ]

  
# File 'lib/redis/commands/modules/search/result.rb', line 197

def [](index)
  @rows[index]
end

#each {|row| ... } ⇒ Enumerator, Array<Hash>

Iterate over the result rows.

Yield Parameters:

  • row (Hash{String => Object})
[ GitHub ]

  
# File 'lib/redis/commands/modules/search/result.rb', line 191

def each(&block)
  @rows.each(&block)
end

#length

Alias for #size.

[ GitHub ]

  
# File 'lib/redis/commands/modules/search/result.rb', line 205

alias length size

#sizeInteger Also known as: #length

Returns:

  • (Integer)

    the number of rows

[ GitHub ]

  
# File 'lib/redis/commands/modules/search/result.rb', line 202

def size
  @rows.size
end