Class: ElasticGraph::SchemaDefinition::Indexing::FieldType::Union Private

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Instance Attribute Details

#subtypes_by_nameHash<String, Object> (readonly)

Returns the subtypes of the union, keyed by name.

Returns:

  • (Hash<String, Object>)

    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_mappingHash<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.

Returns:

  • (Hash<String, ::Object>)

    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