Module: ElasticRecord::Index::Mapping

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

Instance Method Summary collapse

Instance Method Details

#get_mapping(index_name = alias_name) ⇒ Object



8
9
10
11
12
13
14
# File 'lib/elastic_record/index/mapping.rb', line 8

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

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

#mapping_bodyObject



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

def mapping_body
  doctypes.each_with_object({}) do |doctype, result|
    result[doctype.name] = doctype.mapping
  end
end

#update_mapping(index_name = alias_name) ⇒ Object



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

def update_mapping(index_name = alias_name)
  connection.json_put "/#{index_name}/_mapping", mapping_body
end