Class: Redis::Commands::Search::Field
| Relationships & Source Files | |
| Extension / Inclusion / Inheritance Descendants | |
|
Subclasses:
|
|
| Inherits: | Object |
| Defined in: | lib/redis/commands/modules/search/field.rb |
Overview
Base class for a single field in a ::Redis Query Engine SCHEMA (the
field list passed to FT.CREATE). Subclasses describe the field type
(+TEXT+, TAG, NUMERIC, GEO, GEOSHAPE, VECTOR).
Class Method Summary
-
.new(name, type, query = nil, **options) ⇒ Field
constructor
Build a field definition.
Instance Attribute Summary
- #alias_name readonly
- #name readonly
- #options readonly
- #query rw
- #type readonly
Instance Method Summary
-
#to_args ⇒ Array
Render this field as the array of
FT.CREATESCHEMAtokens.
Constructor Details
.new(name, type, query = nil, **options) ⇒ Field
Build a field definition.
Instance Attribute Details
#alias_name (readonly)
[ GitHub ]#name (readonly)
[ GitHub ]# File 'lib/redis/commands/modules/search/field.rb', line 10
attr_reader :name, :type, :, :alias_name
#options (readonly)
[ GitHub ]# File 'lib/redis/commands/modules/search/field.rb', line 10
attr_reader :name, :type, :, :alias_name
#query (rw)
[ GitHub ]# File 'lib/redis/commands/modules/search/field.rb', line 11
attr_accessor :query
#type (readonly)
[ GitHub ]# File 'lib/redis/commands/modules/search/field.rb', line 10
attr_reader :name, :type, :, :alias_name
Instance Method Details
#to_args ⇒ Array
Render this field as the array of FT.CREATE SCHEMA tokens.
# File 'lib/redis/commands/modules/search/field.rb', line 42
def to_args args = [@name] args << "AS" << @alias_name if @alias_name args << @type.to_s.upcase # Add type-specific options first (separator, casesensitive for TAG) if @type == :tag args << "SEPARATOR" << @options[:separator] if @options[:separator] args << "CASESENSITIVE" if @options[:case_sensitive] end # 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