123456789_123456789_123456789_123456789_123456789_

Class: Redis::Commands::Search::Predicate

Relationships & Source Files
Extension / Inclusion / Inheritance Descendants
Subclasses:
Inherits: Object
Defined in: lib/redis/commands/modules/search/query.rb

Overview

Abstract base for a single query-string predicate. Subclasses render themselves into a query-string fragment via #to_s.

Constant Summary

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.new(field) ⇒ Predicate

Parameters:

  • field (String)

    the field name

[ GitHub ]

  
# File 'lib/redis/commands/modules/search/query.rb', line 630

def initialize(field)
  @field = field
end

Instance Attribute Details

#fieldString (readonly)

Returns:

  • (String)

    the field the predicate applies to

[ GitHub ]

  
# File 'lib/redis/commands/modules/search/query.rb', line 615

attr_reader :field

Instance Method Details

#escape_tag(value) (private)

Escape query metacharacters in a literal tag value, including whitespace.

[ GitHub ]

  
# File 'lib/redis/commands/modules/search/query.rb', line 648

def escape_tag(value)
  value.to_s.gsub(TAG_ESCAPE_PATTERN) { |char| "\\#{char}" }
end

#escape_text(value) (private)

Escape query metacharacters in a literal text value, keeping spaces as term separators.

[ GitHub ]

  
# File 'lib/redis/commands/modules/search/query.rb', line 643

def escape_text(value)
  value.to_s.gsub(TEXT_ESCAPE_PATTERN) { |char| "\\#{char}" }
end

#to_sString

Returns:

  • (String)

    the query-string fragment

Raises:

  • (NotImplementedError)

    always; subclasses must override

[ GitHub ]

  
# File 'lib/redis/commands/modules/search/query.rb', line 636

def to_s
  raise NotImplementedError
end