Module: ElasticRecord::Index::Mapping
- Included in:
- ElasticRecord::Index
- Defined in:
- lib/elastic_record/index/mapping.rb
Instance Method Summary collapse
- #get_mapping(index_name = alias_name) ⇒ Object
- #mapping ⇒ Object
- #mapping=(custom_mapping) ⇒ Object
- #update_mapping(index_name = alias_name) ⇒ Object
Instance Method Details
#get_mapping(index_name = alias_name) ⇒ Object
12 13 14 15 16 17 |
# File 'lib/elastic_record/index/mapping.rb', line 12 def get_mapping(index_name = alias_name) json = connection.json_get "/#{index_name}/#{type}/_mapping" unless json.empty? json.values.first['mappings'] end end |
#mapping ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/elastic_record/index/mapping.rb', line 19 def mapping @mapping ||= { properties: { }, _all: { enabled: false }, dynamic_templates: [ { no_string_analyzing: { match: "*", match_mapping_type: "string", mapping: { type: "string", index: "not_analyzed" } } } ] } end |
#mapping=(custom_mapping) ⇒ Object
4 5 6 |
# File 'lib/elastic_record/index/mapping.rb', line 4 def mapping=(custom_mapping) mapping.deep_merge!(custom_mapping) end |
#update_mapping(index_name = alias_name) ⇒ Object
8 9 10 |
# File 'lib/elastic_record/index/mapping.rb', line 8 def update_mapping(index_name = alias_name) connection.json_put "/#{index_name}/#{type}/_mapping", type => mapping end |