Class: ElasticGraph::SchemaDefinition::Indexing::FieldType::Object Private

Inherits:
Object
  • Object
show all
Defined in:
elasticgraph-schema_definition/lib/elastic_graph/schema_definition/indexing/field_type/object.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.

Responsible for the mapping of a SchemaElements::ObjectType.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#mapping_optionsHash<String, ::Object> (readonly)

Returns options to be included in the mapping.

Returns:

  • (Hash<String, ::Object>)

    options to be included in the mapping



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'elasticgraph-schema_definition/lib/elastic_graph/schema_definition/indexing/field_type/object.rb', line 27

class Object < Support::MemoizableData.define(:schema_def_state, :type_name, :subfields, :mapping_options)
  # @return [Hash<String, ::Object>] the datastore mapping for this object type.
  def to_mapping
    @to_mapping ||= begin
      base_mapping = Field.normalized_mapping_hash_for(subfields)
      # When a custom mapping type is used, we need to omit `properties`, because custom mapping
      # types generally don't use `properties` (and if you need to use `properties` with a custom
      # type, you're responsible for defining the properties).
      base_mapping = base_mapping.except("properties") if (mapping_options[:type] || "object") != "object"
      base_mapping.merge(Support::HashUtil.stringify_keys(mapping_options))
    end
  end

  # @private
  def after_initialize
    subfields.freeze
  end
end

#subfieldsArray<Field> (readonly)

Returns the subfields of this object type.

Returns:

  • (Array<Field>)

    the subfields of this object type



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'elasticgraph-schema_definition/lib/elastic_graph/schema_definition/indexing/field_type/object.rb', line 27

class Object < Support::MemoizableData.define(:schema_def_state, :type_name, :subfields, :mapping_options)
  # @return [Hash<String, ::Object>] the datastore mapping for this object type.
  def to_mapping
    @to_mapping ||= begin
      base_mapping = Field.normalized_mapping_hash_for(subfields)
      # When a custom mapping type is used, we need to omit `properties`, because custom mapping
      # types generally don't use `properties` (and if you need to use `properties` with a custom
      # type, you're responsible for defining the properties).
      base_mapping = base_mapping.except("properties") if (mapping_options[:type] || "object") != "object"
      base_mapping.merge(Support::HashUtil.stringify_keys(mapping_options))
    end
  end

  # @private
  def after_initialize
    subfields.freeze
  end
end

#type_nameString (readonly)

Returns name of the object type.

Returns:

  • (String)

    name of the object type



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'elasticgraph-schema_definition/lib/elastic_graph/schema_definition/indexing/field_type/object.rb', line 27

class Object < Support::MemoizableData.define(:schema_def_state, :type_name, :subfields, :mapping_options)
  # @return [Hash<String, ::Object>] the datastore mapping for this object type.
  def to_mapping
    @to_mapping ||= begin
      base_mapping = Field.normalized_mapping_hash_for(subfields)
      # When a custom mapping type is used, we need to omit `properties`, because custom mapping
      # types generally don't use `properties` (and if you need to use `properties` with a custom
      # type, you're responsible for defining the properties).
      base_mapping = base_mapping.except("properties") if (mapping_options[:type] || "object") != "object"
      base_mapping.merge(Support::HashUtil.stringify_keys(mapping_options))
    end
  end

  # @private
  def after_initialize
    subfields.freeze
  end
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 object type.

Returns:

  • (Hash<String, ::Object>)

    the datastore mapping for this object type.



29
30
31
32
33
34
35
36
37
38
# File 'elasticgraph-schema_definition/lib/elastic_graph/schema_definition/indexing/field_type/object.rb', line 29

def to_mapping
  @to_mapping ||= begin
    base_mapping = Field.normalized_mapping_hash_for(subfields)
    # When a custom mapping type is used, we need to omit `properties`, because custom mapping
    # types generally don't use `properties` (and if you need to use `properties` with a custom
    # type, you're responsible for defining the properties).
    base_mapping = base_mapping.except("properties") if (mapping_options[:type] || "object") != "object"
    base_mapping.merge(Support::HashUtil.stringify_keys(mapping_options))
  end
end