Class: Redis::Commands::Search::Field
- Inherits:
-
Object
- Object
- Redis::Commands::Search::Field
- 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).
Direct Known Subclasses
GeoField, GeoShapeField, NumericField, TagField, TextField, VectorField
Instance Attribute Summary collapse
-
#alias_name ⇒ Object
readonly
Returns the value of attribute alias_name.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#query ⇒ Object
Returns the value of attribute query.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(name, type, query = nil, **options) ⇒ Field
constructor
Build a field definition.
-
#to_args ⇒ Array
Render this field as the array of
FT.CREATESCHEMAtokens.
Constructor Details
#initialize(name, type, query = nil, **options) ⇒ Field
Build a field definition.
27 28 29 30 31 32 33 |
# File 'lib/redis/commands/modules/search/field.rb', line 27 def initialize(name, type, query = nil, **) @name = name.to_s @type = type @query = query @options = @alias_name = .delete(:as) end |
Instance Attribute Details
#alias_name ⇒ Object (readonly)
Returns the value of attribute alias_name.
10 11 12 |
# File 'lib/redis/commands/modules/search/field.rb', line 10 def alias_name @alias_name end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
10 11 12 |
# File 'lib/redis/commands/modules/search/field.rb', line 10 def name @name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
10 11 12 |
# File 'lib/redis/commands/modules/search/field.rb', line 10 def @options end |
#query ⇒ Object
Returns the value of attribute query.
11 12 13 |
# File 'lib/redis/commands/modules/search/field.rb', line 11 def query @query end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
10 11 12 |
# File 'lib/redis/commands/modules/search/field.rb', line 10 def type @type end |
Instance Method Details
#to_args ⇒ Array
Render this field as the array of FT.CREATE SCHEMA tokens.
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# 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 |