Skip to content

Commit 582e6fc

Browse files
committed
Fix bug in index type naming found by the test suite.
1 parent 830bc8f commit 582e6fc

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

lib/logstash/outputs/elasticsearch.rb

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,13 +302,20 @@ def start_local_elasticsearch
302302
public
303303
def receive(event)
304304
return unless output?(event)
305-
buffer_receive([event, event.sprintf(@index), event.sprintf(@index_type)])
305+
buffer_receive([event, index, type])
306306
end # def receive
307307

308308
def flush(events, teardown=false)
309309
request = @client.bulk
310310
events.each do |event, index, type|
311-
type = "logs" if type.empty?
311+
index = event.sprintf(@index)
312+
313+
# Set the 'type' value for the index.
314+
if @index_type.nil?
315+
type = event["type"] || "logs"
316+
else
317+
type = event.sprintf(@index_type)
318+
end
312319
if @document_id
313320
request.index(index, type, event.sprintf(@document_id), event.to_json)
314321
else

0 commit comments

Comments
 (0)