123456789_123456789_123456789_123456789_123456789_

Class: Redis::Commands::Search::HybridSearchQuery

Relationships & Source Files
Inherits: Object
Defined in: lib/redis/commands/modules/search/hybrid.rb

Overview

The textual SEARCH leg of an FT.HYBRID query.

Chainable setters (+scorer+, #yield_score_as) return self; #args renders the leg into its argument tokens, beginning with "SEARCH".

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.new(query_string, scorer: nil, yield_score_as: nil) ⇒ HybridSearchQuery

Parameters:

  • query_string (String)

    the search query string

  • scorer (String, nil)

    the scoring function

  • yield_score_as (String, nil)

    the alias to expose the search score under

[ GitHub ]

  
# File 'lib/redis/commands/modules/search/hybrid.rb', line 17

def initialize(query_string, scorer: nil, yield_score_as: nil)
  @query_string = query_string
  @scorer = scorer
  @yield_score_as = yield_score_as
end

Instance Attribute Details

#query_stringString (readonly)

Returns:

  • (String)

    the search query string

[ GitHub ]

  
# File 'lib/redis/commands/modules/search/hybrid.rb', line 12

attr_reader :query_string

Instance Method Details

#argsArray

Returns:

  • (Array)

    the SEARCH leg argument tokens, beginning with "SEARCH"

[ GitHub ]

  
# File 'lib/redis/commands/modules/search/hybrid.rb', line 42

def args
  result = ["SEARCH", @query_string]
  result << "SCORER" << @scorer if @scorer
  result << "YIELD_SCORE_AS" << @yield_score_as if @yield_score_as
  result
end

#scorer(scorer) ⇒ self

Set the scoring function (+SCORER+).

Parameters:

  • scorer (String)

    the scorer name

[ GitHub ]

  
# File 'lib/redis/commands/modules/search/hybrid.rb', line 27

def scorer(scorer)
  @scorer = scorer
  self
end

#yield_score_as(alias_name) ⇒ self

Expose the search score under an alias (+YIELD_SCORE_AS+).

Parameters:

  • alias_name (String)

    the alias for the score

[ GitHub ]

  
# File 'lib/redis/commands/modules/search/hybrid.rb', line 36

def yield_score_as(alias_name)
  @yield_score_as = alias_name
  self
end