Skip to content

Commit

Permalink
Improve handling of Index templates across ES versions.
Browse files Browse the repository at this point in the history
  • Loading branch information
Gavin Williams committed Jun 18, 2020
1 parent 25bce64 commit 536e789
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 174 deletions.
22 changes: 22 additions & 0 deletions spec/fixtures/templates/6.x.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"index_patterns": ["te*", "bar*"],
"settings": {
"number_of_shards": 1
},
"mappings": {
"_doc": {
"_source": {
"enabled": false
},
"properties": {
"host_name": {
"type": "keyword"
},
"created_at": {
"type": "date",
"format": "EEE MMM dd HH:mm:ss Z yyyy"
}
}
}
}
}
22 changes: 22 additions & 0 deletions spec/fixtures/templates/7.x.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"index_patterns": ["te*", "bar*"],
"settings": {
"number_of_shards": 1
},
"mappings": {
"_doc": {
"_source": {
"enabled": false
},
"properties": {
"host_name": {
"type": "keyword"
},
"created_at": {
"type": "date",
"format": "EEE MMM dd HH:mm:ss Z yyyy"
}
}
}
}
}
59 changes: 0 additions & 59 deletions spec/fixtures/templates/post_6.0.json

This file was deleted.

75 changes: 24 additions & 51 deletions spec/fixtures/templates/post_8.0.json
Original file line number Diff line number Diff line change
@@ -1,57 +1,30 @@
{
"index_patterns": [ "logstash-*" ],
"version": 123,
"settings": {
"index": {
"refresh_interval": "5s",
"analysis": {
"analyzer": {
"default": {
"type": "standard",
"stopwords": "_none_"
}
}
}
}
},
"mappings": {
"dynamic_templates": [
{
"string_fields": {
"match": "*",
"match_mapping_type": "string",
"mapping": {
"type": "multi_field",
"fields": {
"{name}": {
"type": "text",
"index": "analyzed",
"omit_norms": true
},
"raw": {
"type ": "text",
"index": "not_analyzed",
"ignore_above": 256
}
}
}
}
}
],
"properties": {
"@version": {
"type": "text",
"index": false
"index_patterns": ["te*", "bar*"],
"template": {
"settings": {
"number_of_shards": 1
},
"mappings": {
"_source": {
"enabled": false
},
"geoip": {
"type": "object",
"dynamic": true,
"properties": {
"location": {
"type": "geo_point"
}
"properties": {
"host_name": {
"type": "keyword"
},
"created_at": {
"type": "date",
"format": "EEE MMM dd HH:mm:ss Z yyyy"
}
}
},
"aliases": {
"mydata": { }
}
},
"priority": 10,
"version": 3,
"_meta": {
"description": "my custom"
}
}
}
61 changes: 0 additions & 61 deletions spec/fixtures/templates/pre_6.0.json

This file was deleted.

6 changes: 3 additions & 3 deletions spec/spec_helper_acceptance.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@
v[:elasticsearch_full_version] = ENV['ELASTICSEARCH_VERSION'] || v[:snapshot_version]
v[:elasticsearch_major_version] = v[:elasticsearch_full_version].split('.').first.to_i
v[:elasticsearch_package] = {}
v[:template] = if v[:elasticsearch_major_version] < 6
JSON.load(File.new('spec/fixtures/templates/pre_6.0.json'))
v[:template] = if v[:elasticsearch_major_version] == 6
JSON.load(File.new('spec/fixtures/templates/6.x.json'))
elsif v[:elasticsearch_major_version] >= 8
JSON.load(File.new('spec/fixtures/templates/post_8.0.json'))
else
JSON.load(File.new('spec/fixtures/templates/post_6.0.json'))
JSON.load(File.new('spec/fixtures/templates/7.x.json'))
end
v[:template] = Puppet_X::Elastic.deep_to_i(Puppet_X::Elastic.deep_to_s(v[:template]))
v[:pipeline] = JSON.load(File.new('spec/fixtures/pipelines/example.json'))
Expand Down

0 comments on commit 536e789

Please sign in to comment.