Class: Redis::Commands::Search::TextField
| Relationships & Source Files | |
| Super Chains via Extension / Inclusion / Inheritance | |
|
Class Chain:
self,
Field
|
|
|
Instance Chain:
self,
Field
|
|
| Inherits: |
Redis::Commands::Search::Field
|
| Defined in: | lib/redis/commands/modules/search/field.rb |
Overview
A TEXT field, indexing full-text searchable content.
Class Method Summary
-
.new(name, query = nil, **options) ⇒ TextField
constructor
Build a
TEXTfield.
Field - Inherited
| .new | Build a field definition. |
Instance Attribute Summary
Instance Method Summary
-
#match(pattern, raw: false) ⇒ Query
Add a text-match predicate (+@field:(pattern)+) to the bound query.
-
#to_args ⇒ Array
Render this field as the array of
FT.CREATESCHEMAtokens.
Field - Inherited
| #to_args | Render this field as the array of |
Constructor Details
.new(name, query = nil, **options) ⇒ TextField
Build a TEXT field.
# File 'lib/redis/commands/modules/search/field.rb', line 95
def initialize(name, query = nil, **) super(name, :text, query, **) if [:phonetic] valid_matchers = ['dm:en', 'dm:fr', 'dm:pt', 'dm:es'] unless valid_matchers.include?([:phonetic]) raise ArgumentError, "Invalid phonetic matcher. Supported matchers are: #{valid_matchers.join(', ')}" end end end
Instance Method Details
#match(pattern, raw: false) ⇒ Query
Add a text-match predicate (+@field:(pattern)+) to the bound query.
# File 'lib/redis/commands/modules/search/field.rb', line 133
def match(pattern, raw: false) query.add_predicate(TextMatchPredicate.new(@alias_name || name, pattern, raw: raw)) end
#to_args ⇒ Array
Render this field as the array of FT.CREATE SCHEMA tokens.
# File 'lib/redis/commands/modules/search/field.rb', line 108
def to_args args = [@name] args << "AS" << @alias_name if @alias_name args << @type.to_s.upcase args << "NOSTEM" if @options[:no_stem] args << "WEIGHT" << @options[:weight].to_s if @options[:weight] args << "PHONETIC" << @options[:phonetic] if @options[:phonetic] # Add suffix options in specific order: no_index, index_missing, index_empty, sortable, withsuffixtrie args << "NOINDEX" if @options[:no_index] args << "INDEXMISSING" if @options[:index_missing] args << "INDEXEMPTY" if @options[:index_empty] args << "SORTABLE" if @options[:sortable] args << "WITHSUFFIXTRIE" if @options[:withsuffixtrie] args end