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).
-
use_updates_for_indexing: when ‘true`, opts the index into using the `update` API instead of the `index` API for indexing. (Defaults to `true`).
Defined Under Namespace
Classes: CustomTimestampRange
Class Method Summary collapse
- .definitions_by_name_hash_from(index_def_hash_by_name) ⇒ Object
- .from(custom_timestamp_ranges:, use_updates_for_indexing: true, **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.
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/elastic_graph/datastore_core/configuration/index_definition.rb', line 39 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 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
66 67 68 69 70 |
# File 'lib/elastic_graph/datastore_core/configuration/index_definition.rb', line 66 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:, use_updates_for_indexing: true, **rest) ⇒ Object
72 73 74 75 76 77 78 |
# File 'lib/elastic_graph/datastore_core/configuration/index_definition.rb', line 72 def self.from(custom_timestamp_ranges:, use_updates_for_indexing: true, **rest) __skip__ = new( custom_timestamp_ranges: CustomTimestampRange.ranges_from(), use_updates_for_indexing: use_updates_for_indexing, **rest ) end |
Instance Method Details
#custom_timestamp_range_for(timestamp) ⇒ Object
60 61 62 63 64 |
# File 'lib/elastic_graph/datastore_core/configuration/index_definition.rb', line 60 def () .find do |range| range.time_set.member?() end end |
#without_env_overrides ⇒ Object
56 57 58 |
# File 'lib/elastic_graph/datastore_core/configuration/index_definition.rb', line 56 def without_env_overrides with(setting_overrides: {}, setting_overrides_by_timestamp: {}, custom_timestamp_ranges: []) end |