Skip to content

Commit dce942f

Browse files
add new include_hits config
1 parent 89e3fd9 commit dce942f

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

lib/logstash/filters/elasticsearch.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ class LogStash::Filters::Elasticsearch < LogStash::Filters::Base
6464
# Whether results should be sorted or not
6565
config :enable_sort, :validate => :boolean, :default => true
6666

67+
# Whether to set hits to metadata
68+
config :include_hits, :validate => :boolean, :default => true
69+
6770
# How many results to return
6871
config :result_size, :validate => :number, :default => 1
6972

@@ -116,6 +119,9 @@ def filter(event)
116119

117120
resultsHits = results["hits"]["hits"]
118121
if !resultsHits.nil? && !resultsHits.empty?
122+
if @include_hits
123+
event.set("[@metadata][hits]", resultsHits)
124+
end
119125
matched = true
120126
@fields.each do |old_key, new_key|
121127
old_key_path = extract_path(old_key)

0 commit comments

Comments
 (0)