Class: ActiveRecord::ConnectionAdapters::Elasticsearch::TableSettingDefinition

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Validations, AttributeMethods
Defined in:
lib/active_record/connection_adapters/elasticsearch/schema_definitions/table_setting_definition.rb

Constant Summary collapse

IGNORE_NAMES =

exclude settings, that are provided through the API but are not part of the index-settings API

['provided_name', 'creation_date', 'uuid', 'version','routing.allocation.initial_recovery','resize'].freeze
FINAL_NAMES =

final names can only be set during index creation

['number_of_shards', 'routing_partition_size', 'soft_deletes.enabled'].freeze
STATIC_NAMES =

static names can only be set during index creation or closed

['number_of_routing_shards', 'codec',
'soft_deletes.retention_lease.period',
'load_fixed_bitset_filters_eagerly', 'shard.check_on_startup',

# modules
'analysis', 'routing', 'unassigned', 'merge', 'similarity', 'search', 'store', 'translog',
'indexing_pressure'].freeze
DYNAMIC_NAMES =

dynamic names can always be changed

['number_of_replicas', 'auto_expand_replicas', "search.idle.after", 'refresh_interval',
'max_result_window', 'max_inner_result_window', 'max_rescore_window',
'max_docvalue_fields_search', 'max_script_fields', 'max_ngram_diff', 'max_shingle_diff',
'max_refresh_listeners', 'analyze.max_token_count', 'highlight.max_analyzed_offset',
'max_terms_count', 'max_regex_length', 'query.default_field', 'routing.allocation.enable',
'routing.rebalance.enable', 'gc_deletes', 'default_pipeline', 'final_pipeline',
'hidden', 'blocks'].freeze
VALID_NAMES =
(FINAL_NAMES + STATIC_NAMES + DYNAMIC_NAMES).freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, value) ⇒ TableSettingDefinition

Returns a new instance of TableSettingDefinition.



74
75
76
77
# File 'lib/active_record/connection_adapters/elasticsearch/schema_definitions/table_setting_definition.rb', line 74

def initialize(name, value)
  @name  = name.to_s
  @value = value
end

Instance Attribute Details

#nameObject

attributes



42
43
44
# File 'lib/active_record/connection_adapters/elasticsearch/schema_definitions/table_setting_definition.rb', line 42

def name
  @name
end

#stateObject (readonly) Originally defined in module AttributeMethods

Returns the value of attribute state.

#valueObject

Returns the value of attribute value.



43
44
45
# File 'lib/active_record/connection_adapters/elasticsearch/schema_definitions/table_setting_definition.rb', line 43

def value
  @value
end

Class Method Details

.match_dynamic_names?(name) ⇒ Boolean

Returns:

  • (Boolean)


66
67
68
# File 'lib/active_record/connection_adapters/elasticsearch/schema_definitions/table_setting_definition.rb', line 66

def self.match_dynamic_names?(name)
  DYNAMIC_NAMES.any? { |invalid| name.match?(invalid) }
end

.match_final_names?(name) ⇒ Boolean

Returns:

  • (Boolean)


62
63
64
# File 'lib/active_record/connection_adapters/elasticsearch/schema_definitions/table_setting_definition.rb', line 62

def self.match_final_names?(name)
  FINAL_NAMES.any? { |invalid| name.match?(invalid) }
end

.match_ignore_names?(name) ⇒ Boolean

Returns:

  • (Boolean)


54
55
56
# File 'lib/active_record/connection_adapters/elasticsearch/schema_definitions/table_setting_definition.rb', line 54

def self.match_ignore_names?(name)
  IGNORE_NAMES.any? { |invalid| name.match?(invalid) }
end

.match_static_names?(name) ⇒ Boolean

Returns:

  • (Boolean)


70
71
72
# File 'lib/active_record/connection_adapters/elasticsearch/schema_definitions/table_setting_definition.rb', line 70

def self.match_static_names?(name)
  STATIC_NAMES.any? { |invalid| name.match?(invalid) }
end

.match_valid_names?(name) ⇒ Boolean

Returns:

  • (Boolean)


58
59
60
# File 'lib/active_record/connection_adapters/elasticsearch/schema_definitions/table_setting_definition.rb', line 58

def self.match_valid_names?(name)
  VALID_NAMES.any? { |invalid| name.match?(invalid) }
end

Instance Method Details

#dynamic?Boolean

Returns:

  • (Boolean)


89
90
91
92
# File 'lib/active_record/connection_adapters/elasticsearch/schema_definitions/table_setting_definition.rb', line 89

def dynamic?
  @dynamic = flat_names.all? { |flat_name| self.class.match_dynamic_names?(flat_name) } if @dynamic.nil?
  @dynamic
end

#error_messagesObject Originally defined in module AttributeMethods

#final?Boolean

Returns:

  • (Boolean)


79
80
81
82
# File 'lib/active_record/connection_adapters/elasticsearch/schema_definitions/table_setting_definition.rb', line 79

def final?
  @final = flat_names.all? { |flat_name| self.class.match_final_names?(flat_name) } if @final.nil?
  @final
end

#flat_namesObject

returns a array of flat names



95
96
97
# File 'lib/active_record/connection_adapters/elasticsearch/schema_definitions/table_setting_definition.rb', line 95

def flat_names
  @flat_names ||= _generate_flat_names.uniq
end

#state?Boolean Originally defined in module AttributeMethods

Returns:

  • (Boolean)

#static?Boolean

Returns:

  • (Boolean)


84
85
86
87
# File 'lib/active_record/connection_adapters/elasticsearch/schema_definitions/table_setting_definition.rb', line 84

def static?
  @static = flat_names.all? { |flat_name| self.class.match_static_names?(flat_name) } if @static.nil?
  @static
end

#with_state(state) ⇒ Object Originally defined in module AttributeMethods