Class: ElasticGraph::SchemaDefinition::Indexing::FieldType::Union Private
- Inherits:
-
Object
- Object
- ElasticGraph::SchemaDefinition::Indexing::FieldType::Union
- Defined in:
- elasticgraph-schema_definition/lib/elastic_graph/schema_definition/indexing/field_type/union.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Note:
Within the mapping, we have a single object type that has a set union of the properties
of the subtypes (and also a __typename keyword field).
Responsible for the mapping of a SchemaElements::UnionType.
Instance Attribute Summary collapse
-
#subtypes_by_name ⇒ Hash<String, Object>
readonly
The subtypes of the union, keyed by name.
Instance Method Summary collapse
-
#to_mapping ⇒ Hash<String, ::Object>
private
The datastore mapping for this union type.
Instance Attribute Details
#subtypes_by_name ⇒ Hash<String, Object> (readonly)
Returns the subtypes of the union, keyed by name.
25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'elasticgraph-schema_definition/lib/elastic_graph/schema_definition/indexing/field_type/union.rb', line 25 class Union < ::Data.define(:subtypes_by_name) # @return [Hash<String, ::Object>] the datastore mapping for this union type. def to_mapping mapping_subfields = subtypes_by_name.values.map(&:subfields).reduce([], :union) Support::HashUtil.deep_merge( Field.normalized_mapping_hash_for(mapping_subfields), {"properties" => {"__typename" => {"type" => "keyword"}}} ) end # @dynamic initialize, subtypes_by_name end |
Instance Method Details
#to_mapping ⇒ Hash<String, ::Object>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the datastore mapping for this union type.
27 28 29 30 31 32 33 34 |
# File 'elasticgraph-schema_definition/lib/elastic_graph/schema_definition/indexing/field_type/union.rb', line 27 def to_mapping mapping_subfields = subtypes_by_name.values.map(&:subfields).reduce([], :union) Support::HashUtil.deep_merge( Field.normalized_mapping_hash_for(mapping_subfields), {"properties" => {"__typename" => {"type" => "keyword"}}} ) end |