123456789_123456789_123456789_123456789_123456789_

Class: Redis::Commands::Search::SearchResult

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.SEARCH: the total number of matching documents (which may exceed the number returned because of paging) plus the documents on this page.

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.new(total, documents, warnings: []) ⇒ SearchResult

Parameters:

  • total (Integer)

    the total number of matching documents

  • documents (Array<Document>)

    the documents on this page

  • warnings (Array<String>)

    any warnings returned by the server

[ GitHub ]

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

def initialize(total, documents, warnings: [])
  @total = total
  @documents = documents
  @warnings = warnings
end

Instance Attribute Details

#documentsInteger, ... (readonly)

Returns:

  • (Integer)

    the total number of matching documents (may exceed documents.size because of paging)

  • (Array<Document>)

    the documents on this page

  • (Array<String>)

    any warnings returned by the server (e.g. a query timeout under the return policy); only the RESP3 wire carries warnings on FT.SEARCH, so this is always empty on RESP2 connections

[ GitHub ]

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

attr_reader :total, :documents, :warnings

#empty?Boolean (readonly)

Returns:

  • (Boolean)

    whether this page has no documents

[ GitHub ]

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

def empty?
  @documents.empty?
end

#totalInteger, ... (readonly)

Returns:

  • (Integer)

    the total number of matching documents (may exceed documents.size because of paging)

  • (Array<Document>)

    the documents on this page

  • (Array<String>)

    any warnings returned by the server (e.g. a query timeout under the return policy); only the RESP3 wire carries warnings on FT.SEARCH, so this is always empty on RESP2 connections

[ GitHub ]

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

attr_reader :total, :documents, :warnings

#warningsInteger, ... (readonly)

Returns:

  • (Integer)

    the total number of matching documents (may exceed documents.size because of paging)

  • (Array<Document>)

    the documents on this page

  • (Array<String>)

    any warnings returned by the server (e.g. a query timeout under the return policy); only the RESP3 wire carries warnings on FT.SEARCH, so this is always empty on RESP2 connections

[ GitHub ]

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

attr_reader :total, :documents, :warnings

Instance Method Details

#[](index) ⇒ Document?

Parameters:

  • index (Integer)

    the position within this page

Returns:

  • (Document, nil)

    the document at index, or nil when out of range

[ GitHub ]

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

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

#each {|document| ... } ⇒ Enumerator, Array<Document>

Iterate over the documents on this page.

Yield Parameters:

[ GitHub ]

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

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

#length

Alias for #size.

[ GitHub ]

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

alias length size

#sizeInteger Also known as: #length

Returns:

  • (Integer)

    the number of documents on this page

[ GitHub ]

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

def size
  @documents.size
end