diff --git a/spec/es_spec_helper.rb b/spec/es_spec_helper.rb index 6e2ea466d..8bd5bf659 100644 --- a/spec/es_spec_helper.rb +++ b/spec/es_spec_helper.rb @@ -30,13 +30,19 @@ def todays_date Time.now.strftime("%Y.%m.%d") end - def mapping_name + + def default_mapping_from_mappings(mappings) if ESHelper.es_version_satisfies?(">=7") - "_doc" + mappings else - "_default_" + mappings["_default_"] end + end + def field_properties_from_template(template_name, field) + mappings = @es.indices.get_template(name: template_name)[template_name]["mappings"] + mapping = default_mapping_from_mappings(mappings) + mapping["properties"][field]["properties"] end def routing_field_name diff --git a/spec/integration/outputs/parent_spec.rb b/spec/integration/outputs/parent_spec.rb index 117ba1b8e..a6bfb38c1 100644 --- a/spec/integration/outputs/parent_spec.rb +++ b/spec/integration/outputs/parent_spec.rb @@ -76,7 +76,15 @@ shared_examples "a join field based parent indexer" do let(:index) { 10.times.collect { rand(10).to_s }.join("") } - let(:type) { 10.times.collect { rand(10).to_s }.join("") } + + let(:type) do + if ESHelper.es_version_satisfies?('<7') + 10.times.collect { rand(10).to_s }.join("") + else + "_doc" + end + end + let(:event_count) { 10000 + rand(500) } let(:parent) { "not_implemented" } let(:config) { "not_implemented" } diff --git a/spec/integration/outputs/templates_5x_spec.rb b/spec/integration/outputs/templates_5x_spec.rb index 2f923a0ed..1959ab73d 100644 --- a/spec/integration/outputs/templates_5x_spec.rb +++ b/spec/integration/outputs/templates_5x_spec.rb @@ -82,7 +82,7 @@ end it "make [geoip][location] a geo_point" do - expect(@es.indices.get_template(name: "logstash")["logstash"]["mappings"][mapping_name]["properties"]["geoip"]["properties"]["location"]["type"]).to eq("geo_point") + expect(field_properties_from_template("logstash", "geoip")["location"]["type"]).to eq("geo_point") end it "aggregate .keyword results correctly " do