123456789_123456789_123456789_123456789_123456789_

Class: Redis::Commands::Search::AggregateResult

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.AGGREGATE (and FT.CURSOR READ): the rows produced by the pipeline plus, when WITHCURSOR was requested, the cursor id to read the next batch with (0 when the cursor is exhausted).

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.new(rows, cursor: nil) ⇒ AggregateResult

Parameters:

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

    the pipeline rows

  • cursor (Integer, nil)

    the next cursor id, or nil when no cursor was requested

[ GitHub ]

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

def initialize(rows, cursor: nil)
  @rows = rows
  @cursor = cursor
end

Instance Attribute Details

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

Returns:

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

    the rows produced by the pipeline, each a field => value hash

  • (Integer, nil)

    the next cursor id (0 when exhausted), or nil when no cursor

[ GitHub ]

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

attr_reader :rows, :cursor

#empty?Boolean (readonly)

Returns:

  • (Boolean)

    whether there are no rows

[ GitHub ]

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

def empty?
  @rows.empty?
end

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

Returns:

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

    the rows produced by the pipeline, each a field => value hash

  • (Integer, nil)

    the next cursor id (0 when exhausted), or nil when no cursor

[ GitHub ]

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

attr_reader :rows, :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 145

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

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

Iterate over the rows.

Yield Parameters:

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

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

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

#length

Alias for #size.

[ GitHub ]

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

alias length size

#sizeInteger Also known as: #length

Returns:

  • (Integer)

    the number of rows

[ GitHub ]

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

def size
  @rows.size
end