Class: Redis::Commands::Search::Predicate
- Inherits:
-
Object
- Object
- Redis::Commands::Search::Predicate
- 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.
Direct Known Subclasses
Constant Summary collapse
- TEXT_SPECIAL_CHARACTERS =
RediSearch query operators/metacharacters. Escaped with a backslash so an interpolated value is matched literally instead of altering (or breaking) the query.
[ ',', '.', '<', '>', '{', '}', '[', ']', '"', "'", ':', ';', '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '-', '+', '=', '~', '|', '/', '\\' ].freeze
- TAG_SPECIAL_CHARACTERS =
TAG values are single literal tokens, so whitespace is significant and must be escaped too. TEXT queries keep spaces, which separate terms (a multi-word match is an AND).
(TEXT_SPECIAL_CHARACTERS + [' ']).freeze
- TEXT_ESCAPE_PATTERN =
Regexp.union(TEXT_SPECIAL_CHARACTERS)
- TAG_ESCAPE_PATTERN =
Regexp.union(TAG_SPECIAL_CHARACTERS)
Instance Attribute Summary collapse
-
#field ⇒ String
readonly
The field the predicate applies to.
Instance Method Summary collapse
-
#initialize(field) ⇒ Predicate
constructor
A new instance of Predicate.
-
#to_s ⇒ String
The query-string fragment.
Constructor Details
#initialize(field) ⇒ Predicate
Returns a new instance of Predicate.
630 631 632 |
# File 'lib/redis/commands/modules/search/query.rb', line 630 def initialize(field) @field = field end |
Instance Attribute Details
#field ⇒ String (readonly)
Returns the field the predicate applies to.
615 616 617 |
# File 'lib/redis/commands/modules/search/query.rb', line 615 def field @field end |
Instance Method Details
#to_s ⇒ String
Returns the query-string fragment.
636 637 638 |
# File 'lib/redis/commands/modules/search/query.rb', line 636 def to_s raise NotImplementedError end |