Module: ElasticRecord::Index::Mapping

Included in:
ElasticRecord::Index
Defined in:
lib/elastic_record/index/mapping.rb

Constant Summary collapse

DEFAULT_MAPPING =
{
  properties: {
  }
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#mappingObject

Returns the value of attribute mapping.



4
5
6
# File 'lib/elastic_record/index/mapping.rb', line 4

def mapping
  @mapping
end

Instance Method Details

#get_mapping(index_name = alias_name) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/elastic_record/index/mapping.rb', line 22

def get_mapping(index_name = alias_name)
  json = connection.json_get "/#{index_name}/_mapping?include_type_name=false"

  unless json.empty?
    json.values.first['mappings']
  end
end

#update_mapping(index_name = alias_name) ⇒ Object



18
19
20
# File 'lib/elastic_record/index/mapping.rb', line 18

def update_mapping(index_name = alias_name)
  connection.json_put "/#{index_name}/_mapping?include_type_name=false", mapping
end