lib/fluent/plugin/out_solr.rb in fluent-plugin-output-solr-0.2.3 vs lib/fluent/plugin/out_solr.rb in fluent-plugin-output-solr-0.2.4
- old
+ new
@@ -118,16 +118,19 @@
unless record.has_key?(@timestamp_field) then
record.merge!({@timestamp_field => Time.at(time).utc.strftime('%FT%TZ')})
end
- if @ignore_undefined_fields then
+ log.info record
+
+ if to_boolean(@ignore_undefined_fields) then
record.each_key do |key|
unless @fields.include?(key) then
record.delete(key)
end
end
+ log.info record
end
documents << record
if documents.count >= @flush_size
@@ -135,9 +138,15 @@
documents.clear
end
end
update documents unless documents.empty?
+ end
+
+ def to_boolean(string)
+ return true if string== true || string =~ (/(true|t|yes|y|1)$/i)
+ return false if string== false || string.nil? || string =~ (/(false|f|no|n|0)$/i)
+ raise ArgumentError.new("invalid value for Boolean: \"#{string}\"")
end
def update(documents)
if @mode == MODE_STANDALONE then
@solr.add documents, :params => {:commit => true}