Class: Redis::Commands::Search::IndexDefinition
- Inherits:
-
Object
- Object
- Redis::Commands::Search::IndexDefinition
- Defined in:
- lib/redis/commands/modules/search/index_definition.rb
Overview
The definition portion of an FT.CREATE call: which keyspace the index
is built over and how documents are scored and filtered. Renders into a
token array exposed via #args.
Instance Attribute Summary collapse
- #args ⇒ Array, ... readonly
- #index_type ⇒ Array, ... readonly
- #prefixes ⇒ Array, ... readonly
Instance Method Summary collapse
-
#initialize(prefix: [], filter: nil, language_field: nil, language: nil, score_field: nil, score: 1.0, payload_field: nil, index_type: nil) ⇒ IndexDefinition
constructor
Build an index definition and pre-render its
FT.CREATEtokens.
Constructor Details
#initialize(prefix: [], filter: nil, language_field: nil, language: nil, score_field: nil, score: 1.0, payload_field: nil, index_type: nil) ⇒ IndexDefinition
Build an index definition and pre-render its FT.CREATE tokens.
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/redis/commands/modules/search/index_definition.rb', line 37 def initialize( prefix: [], filter: nil, language_field: nil, language: nil, score_field: nil, score: 1.0, payload_field: nil, index_type: nil ) @args = [] @index_type = index_type # Array() makes the prefix handling nil-safe (nil -> []) and wraps a lone String prefix # into a one-element list, so PREFIX always emits the correct count. dup detaches us from # the caller's list (Array() returns it unchanged when it's already an Array) so later # external mutations can't alter this definition. @prefixes = Array(prefix).dup append_index_type(index_type) append_prefix(@prefixes) append_filter(filter) append_language(language_field, language) append_score(score_field, score) append_payload(payload_field) end |
Instance Attribute Details
#args ⇒ Array, ... (readonly)
19 20 21 |
# File 'lib/redis/commands/modules/search/index_definition.rb', line 19 def args @args end |
#index_type ⇒ Array, ... (readonly)
19 20 21 |
# File 'lib/redis/commands/modules/search/index_definition.rb', line 19 def index_type @index_type end |
#prefixes ⇒ Array, ... (readonly)
19 20 21 |
# File 'lib/redis/commands/modules/search/index_definition.rb', line 19 def prefixes @prefixes end |