Skip to content

Commit 1ba256d

Browse files
jsvdrobbavey
authored andcommitted
remove obsolete fields and obsolete document_type
Fixes #828
1 parent 53c24a8 commit 1ba256d

File tree

4 files changed

+23
-50
lines changed

4 files changed

+23
-50
lines changed

lib/logstash/outputs/elasticsearch/common.rb

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -78,15 +78,11 @@ def event_action_tuple(event)
7878
params[:pipeline] = event.sprintf(@pipeline)
7979
end
8080

81-
if @parent
82-
if @join_field
83-
join_value = event.get(@join_field)
84-
parent_value = event.sprintf(@parent)
85-
event.set(@join_field, { "name" => join_value, "parent" => parent_value })
86-
params[routing_field_name] = event.sprintf(@parent)
87-
else
88-
params[:parent] = event.sprintf(@parent)
89-
end
81+
if @parent && @join_field
82+
join_value = event.get(@join_field)
83+
parent_value = event.sprintf(@parent)
84+
event.set(@join_field, { "name" => join_value, "parent" => parent_value })
85+
params[routing_field_name] = event.sprintf(@parent)
9086
end
9187

9288
if action == 'update'
@@ -260,16 +256,10 @@ def handle_dlq_status(message, action, status, response)
260256
DEFAULT_EVENT_TYPE_ES7="_doc".freeze
261257
def get_event_type(event)
262258
# Set the 'type' value for the index.
263-
type = if @document_type
264-
event.sprintf(@document_type)
259+
type = if client.maximum_seen_major_version < 7
260+
DEFAULT_EVENT_TYPE_ES6
265261
else
266-
if client.maximum_seen_major_version < 6
267-
event.get("type") || DEFAULT_EVENT_TYPE_ES6
268-
elsif client.maximum_seen_major_version == 6
269-
DEFAULT_EVENT_TYPE_ES6
270-
else
271-
DEFAULT_EVENT_TYPE_ES7
272-
end
262+
DEFAULT_EVENT_TYPE_ES7
273263
end
274264

275265
if !(type.is_a?(String) || type.is_a?(Numeric))

lib/logstash/outputs/elasticsearch/common_configs.rb

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ def self.included(mod)
1717
mod.config :index, :validate => :string, :default => DEFAULT_INDEX_NAME
1818

1919
mod.config :document_type,
20-
:validate => :string,
21-
:deprecated => "Document types are being deprecated in Elasticsearch 6.0, and removed entirely in 7.0. You should avoid this feature"
20+
:obsolete => "Multiple document types per index were deprecated in Elasticsearch 6.0 and removed entirely in 7.0. We'll now default to 'doc' on ES 6 and '_doc' in 7"
2221

2322
# From Logstash 1.3 onwards, a template is applied to Elasticsearch during
2423
# Logstash's startup if one with the name `template_name` does not already exist.
@@ -77,7 +76,7 @@ def self.included(mod)
7776
mod.config :routing, :validate => :string
7877

7978
# For child documents, ID of the associated parent.
80-
# This can be dynamic using the `%{foo}` syntax.
79+
# This can be dynamic using the `%{foo}` syntax.:w
8180
mod.config :parent, :validate => :string, :default => nil
8281

8382
# For child documents, name of the join field
@@ -96,10 +95,6 @@ def self.included(mod)
9695
# Any special characters present in the URLs here MUST be URL escaped! This means `#` should be put in as `%23` for instance.
9796
mod.config :hosts, :validate => :uri, :default => [::LogStash::Util::SafeURI.new("//127.0.0.1")], :list => true
9897

99-
mod.config :flush_size, :validate => :number, :obsolete => "This setting is no longer available as we now try to restrict bulk requests to sane sizes. See the 'Batch Sizes' section of the docs. If you think you still need to restrict payloads based on the number, not size, of events, please open a ticket."
100-
101-
mod.config :idle_flush_time, :validate => :number, :obsolete => "This settings is no longer valid. This was a no-op now as every pipeline batch is flushed synchronously obviating the need for this option."
102-
10398
# Set upsert content for update mode.s
10499
# Create a new document with this parameter as json string if `document_id` doesn't exists
105100
mod.config :upsert, :validate => :string, :default => ""

spec/integration/outputs/parent_spec.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,6 @@
151151
"hosts" => get_host_port,
152152
"index" => index,
153153
"parent" => parent_id,
154-
"document_type" => type,
155154
"join_field" => join_field,
156155
"manage_template" => false
157156
}
@@ -166,7 +165,6 @@
166165
"hosts" => get_host_port,
167166
"index" => index,
168167
"parent" => "%{link_to}",
169-
"document_type" => type,
170168
"join_field" => join_field,
171169
"manage_template" => false
172170
}

spec/unit/outputs/elasticsearch_spec.rb

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -43,34 +43,24 @@
4343
let(:manticore_url) { manticore_urls.first }
4444

4545
describe "getting a document type" do
46-
context "if document_type isn't set" do
47-
let(:options) { super.merge("document_type" => nil)}
48-
context "for 7.x elasticsearch clusters" do
49-
let(:maximum_seen_major_version) { 7 }
50-
it "should return '_doc'" do
51-
expect(subject.send(:get_event_type, LogStash::Event.new("type" => "foo"))).to eql("_doc")
52-
end
53-
end
54-
55-
context "for 6.x elasticsearch clusters" do
56-
let(:maximum_seen_major_version) { 6 }
57-
it "should return 'doc'" do
58-
expect(subject.send(:get_event_type, LogStash::Event.new("type" => "foo"))).to eql("doc")
59-
end
46+
context "for 7.x elasticsearch clusters" do
47+
let(:maximum_seen_major_version) { 7 }
48+
it "should return '_doc'" do
49+
expect(subject.send(:get_event_type, LogStash::Event.new("type" => "foo"))).to eql("_doc")
6050
end
51+
end
6152

62-
context "for < 6.0 elasticsearch clusters" do
63-
let(:maximum_seen_major_version) { 5 }
64-
it "should get the type from the event" do
65-
expect(subject.send(:get_event_type, LogStash::Event.new("type" => "foo"))).to eql("foo")
66-
end
53+
context "for 6.x elasticsearch clusters" do
54+
let(:maximum_seen_major_version) { 6 }
55+
it "should return 'doc'" do
56+
expect(subject.send(:get_event_type, LogStash::Event.new("type" => "foo"))).to eql("doc")
6757
end
6858
end
6959

70-
context "with 'document type set'" do
71-
let(:options) { super.merge("document_type" => "bar")}
72-
it "should get the event type from the 'document_type' setting" do
73-
expect(subject.send(:get_event_type, LogStash::Event.new())).to eql("bar")
60+
context "for < 6.0 elasticsearch clusters" do
61+
let(:maximum_seen_major_version) { 5 }
62+
it "should return 'doc'" do
63+
expect(subject.send(:get_event_type, LogStash::Event.new("type" => "foo"))).to eql("doc")
7464
end
7565
end
7666

0 commit comments

Comments
 (0)