Class: ElasticGraph::DatastoreCore::Configuration::IndexDefinition
- Inherits:
-
Object
- Object
- ElasticGraph::DatastoreCore::Configuration::IndexDefinition
- Defined in:
- lib/elastic_graph/datastore_core/configuration/index_definition.rb
Overview
Defines environment-specific customizations for an index definition.
-
ignore_routing_values: routing values for which we will ignore routing as configured on the index. This is intended to be used when a single routing value contains such a large portion of the dataset that it creates lopsided shards. By including that routing value in this config setting, it’ll spread that value’s data across all shards instead of concentrating it on a single shard.
-
query_cluster: named search cluster to be used for queries on this index.
-
index_into_cluster: named search clusters to index data into.
-
setting_overrides: overrides for index (or index template) settings.
-
setting_overrides_by_timestamp: overrides for index template settings for specific dates, allowing us to have different settings than the template for some timestamp.
-
custom_timestamp_ranges: defines indices for a custom timestamp range (rather than relying on the configured rollover frequency).
Defined Under Namespace
Classes: CustomTimestampRange
Class Method Summary collapse
- .definitions_by_name_hash_from(index_def_hash_by_name) ⇒ Object
- .from(custom_timestamp_ranges:, **rest) ⇒ Object
Instance Method Summary collapse
- #custom_timestamp_range_for(timestamp) ⇒ Object
-
#initialize(ignore_routing_values:, **rest) ⇒ IndexDefinition
constructor
A new instance of IndexDefinition.
- #without_env_overrides ⇒ Object
Constructor Details
#initialize(ignore_routing_values:, **rest) ⇒ IndexDefinition
Returns a new instance of IndexDefinition.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/elastic_graph/datastore_core/configuration/index_definition.rb', line 36 def initialize(ignore_routing_values:, **rest) __skip__ = super(ignore_routing_values: ignore_routing_values.to_set, **rest) # Verify the custom ranges are disjoint. # Yeah, this is O(N^2), which isn't great, but we expect a _very_ small number of custom # ranges (0-2) so this should be ok. return if .map(&:time_set) .combination(2) .none? do |s1_s2| s1, s2 = s1_s2 s1.intersect?(s2) end raise Errors::ConfigError, "Your configured `custom_timestamp_ranges` are not disjoint, as required." end |
Class Method Details
.definitions_by_name_hash_from(index_def_hash_by_name) ⇒ Object
63 64 65 66 67 |
# File 'lib/elastic_graph/datastore_core/configuration/index_definition.rb', line 63 def self.definitions_by_name_hash_from(index_def_hash_by_name) index_def_hash_by_name.transform_values do |index_def_hash| __skip__ = from(**index_def_hash.transform_keys(&:to_sym)) end end |
.from(custom_timestamp_ranges:, **rest) ⇒ Object
69 70 71 72 73 74 |
# File 'lib/elastic_graph/datastore_core/configuration/index_definition.rb', line 69 def self.from(custom_timestamp_ranges:, **rest) __skip__ = new( custom_timestamp_ranges: CustomTimestampRange.ranges_from(), **rest ) end |
Instance Method Details
#custom_timestamp_range_for(timestamp) ⇒ Object
57 58 59 60 61 |
# File 'lib/elastic_graph/datastore_core/configuration/index_definition.rb', line 57 def () .find do |range| range.time_set.member?() end end |
#without_env_overrides ⇒ Object
53 54 55 |
# File 'lib/elastic_graph/datastore_core/configuration/index_definition.rb', line 53 def without_env_overrides with(setting_overrides: {}, setting_overrides_by_timestamp: {}, custom_timestamp_ranges: []) end |