Class: Redis::Commands::Search::TextMatchPredicate
| Relationships & Source Files | |
| Super Chains via Extension / Inclusion / Inheritance | |
|
Class Chain:
self,
Predicate
|
|
|
Instance Chain:
self,
Predicate
|
|
| Inherits: |
Redis::Commands::Search::Predicate
|
| Defined in: | lib/redis/commands/modules/search/query.rb |
Overview
A text-match predicate rendering (@field:(pattern)).
Constant Summary
Predicate - Inherited
TAG_ESCAPE_PATTERN, TAG_SPECIAL_CHARACTERS, TEXT_ESCAPE_PATTERN, TEXT_SPECIAL_CHARACTERS
Class Method Summary
Instance Attribute Summary
Instance Method Summary
Predicate - Inherited
| #to_s, | |
| #escape_tag | Escape query metacharacters in a literal tag value, including whitespace. |
| #escape_text | Escape query metacharacters in a literal text value, keeping spaces as term separators. |
Constructor Details
.new(field, pattern, raw: false) ⇒ TextMatchPredicate
# File 'lib/redis/commands/modules/search/query.rb', line 675
def initialize(field, pattern, raw: false) super(field) @pattern = pattern @raw = raw end
Instance Method Details
#to_s ⇒ String
# File 'lib/redis/commands/modules/search/query.rb', line 682
def to_s # Group the pattern: RediSearch scopes "@field:" only to the term immediately after it, # so a bare "@title:hello world" would match "hello" on the field but "world" globally # (across all fields). Wrapping in parentheses scopes the whole pattern to the field; # it is a no-op for single-term patterns. Unless raw, escape metacharacters so a value # can't inject query syntax. pattern = @raw ? @pattern : escape_text(@pattern) "(@#{@field}:(#{pattern}))" end