Module: ElasticGraph::DatastoreCore::IndexDefinition
- Defined in:
- lib/elastic_graph/datastore_core/index_definition.rb,
lib/elastic_graph/datastore_core/index_definition/base.rb,
lib/elastic_graph/datastore_core/index_definition/index.rb,
lib/elastic_graph/datastore_core/index_definition/rollover_index.rb,
lib/elastic_graph/datastore_core/index_definition/rollover_index_template.rb
Overview
Represents the definition of a datastore index (or rollover template). Intended to be an entry point for working with datastore indices.
This module contains common implementation logic for both the rollover and non-rollover case, as well as a ‘with` factory method.
Defined Under Namespace
Modules: Base Classes: Index, RolloverIndex, RolloverIndexTemplate
Class Method Summary collapse
Class Method Details
.with(name:, runtime_metadata:, config:, datastore_clients_by_name:, schema_artifacts:) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/elastic_graph/datastore_core/index_definition.rb', line 21 def self.with(name:, runtime_metadata:, config:, datastore_clients_by_name:, schema_artifacts:) if (env_index_config = config.index_definitions[name]).nil? raise Errors::ConfigError, "Configuration does not provide an index definition for `#{name}`, " \ "but it is required so we can identify the datastore cluster(s) to query and index into." end common_args = { name: name, route_with: .route_with, default_sort_clauses: .default_sort_fields.map(&:to_query_clause), current_sources: .current_sources, fields_by_path: .fields_by_path, env_index_config: env_index_config, defined_clusters: config.clusters.keys.to_set, datastore_clients_by_name: datastore_clients_by_name, has_had_multiple_sources: .has_had_multiple_sources } if (rollover = .rollover) env_agnostic_settings = schema_artifacts.index_templates.fetch(name).fetch("template").fetch("settings") RolloverIndexTemplate.new( env_agnostic_settings: env_agnostic_settings, timestamp_field_path: rollover., frequency: rollover.frequency, index_args: common_args.merge(env_agnostic_settings: env_agnostic_settings), **common_args ) else Index.new( env_agnostic_settings: schema_artifacts.indices.fetch(name).fetch("settings"), **common_args ) end end |