Skip to content

Commit eba9a53

Browse files
committed
remove major versions specific code for ES < 6
1 parent 9456adb commit eba9a53

File tree

3 files changed

+4
-13
lines changed

3 files changed

+4
-13
lines changed

lib/logstash/outputs/elasticsearch.rb

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ def retry_on_conflict_action_name
443443
end
444444

445445
def routing_field_name
446-
maximum_seen_major_version >= 6 ? :routing : :_routing
446+
:routing
447447
end
448448

449449
# Determine the correct value for the 'type' field for the given event
@@ -456,9 +456,7 @@ def get_event_type(event)
456456
event.sprintf(@document_type)
457457
else
458458
major_version = maximum_seen_major_version
459-
if major_version < 6
460-
es5_event_type(event)
461-
elsif major_version == 6
459+
if major_version == 6
462460
DEFAULT_EVENT_TYPE_ES6
463461
elsif major_version == 7
464462
DEFAULT_EVENT_TYPE_ES7

lib/logstash/outputs/elasticsearch/template_manager.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def self.template_name(plugin)
5353
end
5454

5555
def self.default_template_path(es_major_version, ecs_compatibility=:disabled)
56-
template_version = es_major_version == 1 ? 2 : es_major_version
56+
template_version = es_major_version
5757
default_template_name = "templates/ecs-#{ecs_compatibility}/elasticsearch-#{template_version}x.json"
5858
::File.expand_path(default_template_name, ::File.dirname(__FILE__))
5959
end

spec/unit/outputs/elasticsearch_spec.rb

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
describe LogStash::Outputs::ElasticSearch do
88
subject(:elasticsearch_output_instance) { described_class.new(options) }
99
let(:options) { {} }
10-
let(:maximum_seen_major_version) { [1,2,5,6,7,8].sample }
10+
let(:maximum_seen_major_version) { [6,7,8].sample }
1111

1212
let(:do_register) { true }
1313

@@ -79,13 +79,6 @@
7979
expect(subject.send(:get_event_type, LogStash::Event.new("type" => "foo"))).to eql("doc")
8080
end
8181
end
82-
83-
context "for < 6.0 elasticsearch clusters" do
84-
let(:maximum_seen_major_version) { 5 }
85-
it "should get the type from the event" do
86-
expect(subject.send(:get_event_type, LogStash::Event.new("type" => "foo"))).to eql("foo")
87-
end
88-
end
8982
end
9083

9184
context "with 'document type set'" do

0 commit comments

Comments
 (0)