Skip to content

Commit e91210c

Browse files
committed
The existing behavior is to keep routing => nil in event fields. This commit rollback the changes to satisfy that condition
1 parent cc45a0a commit e91210c

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

lib/logstash/outputs/elasticsearch.rb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -554,11 +554,13 @@ def common_event_params(event)
554554
# }
555555
params[:pipeline] = target_pipeline unless (target_pipeline.nil? || target_pipeline.empty?)
556556

557-
params[:version] = resolve_version(event, event_version)
558-
params[:version_type] = resolve_version_type(event, event_version_type)
557+
resolved_version = resolve_version(event, event_version)
558+
resolved_version_type = resolve_version_type(event, event_version_type)
559+
# avoid to add nil valued key-value pairs
560+
params[:version] = resolved_version unless resolved_version.nil?
561+
params[:version_type] = resolved_version_type unless resolved_version_type.nil?
559562

560-
# purge nil valued key-value pairs
561-
params.compact
563+
params
562564
end
563565

564566
def resolve_version(event, event_version)

spec/unit/outputs/elasticsearch_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@
372372

373373
context "when the event DOESN'T contain an integration metadata routing" do
374374
it "plugin's default id mechanism is used" do
375-
expect(subject.send(:event_action_tuple, event)[1]).to_not include(:routing)
375+
expect(subject.send(:event_action_tuple, event)[1]).to include(:routing => nil)
376376
end
377377
end
378378
end

0 commit comments

Comments
 (0)