1414# .Compatibility Note
1515# [NOTE]
1616# ================================================================================
17- # Starting with Elasticsearch 5.3, there's an {ref}modules-http.html[HTTP setting]
18- # called `http.content_type.required`. If this option is set to `true`, and you
19- # are using Logstash 2.4 through 5.2, you need to update the Elasticsearch output
20- # plugin to version 6.2.5 or higher.
21- #
22- # ================================================================================
2317#
2418# This plugin is the recommended method of storing logs in Elasticsearch.
2519# If you plan on using the Kibana web interface, you'll want to use this output.
2620#
27- # This output only speaks the HTTP protocol. HTTP is the preferred protocol for interacting with Elasticsearch as of Logstash 2.0.
28- # We strongly encourage the use of HTTP over the node protocol for a number of reasons. HTTP is only marginally slower,
29- # yet far easier to administer and work with. When using the HTTP protocol one may upgrade Elasticsearch versions without having
30- # to upgrade Logstash in lock-step.
21+ # This output only speaks the HTTP protocol.
3122#
3223# You can learn more about Elasticsearch at <https://www.elastic.co/products/elasticsearch>
3324#
34- # ==== Template management for Elasticsearch 5.x
35- # Index template for this version (Logstash 5.0) has been changed to reflect Elasticsearch's mapping changes in version 5.0.
36- # Most importantly, the subfield for string multi-fields has changed from `.raw` to `.keyword` to match ES default
37- # behavior.
38- #
39- # ** Users installing ES 5.x and LS 5.x **
40- # This change will not affect you and you will continue to use the ES defaults.
41- #
42- # ** Users upgrading from LS 2.x to LS 5.x with ES 5.x **
43- # LS will not force upgrade the template, if `logstash` template already exists. This means you will still use
44- # `.raw` for sub-fields coming from 2.x. If you choose to use the new template, you will have to reindex your data after
45- # the new template is installed.
46- #
4725# ==== Retry Policy
4826#
49- # The retry policy has changed significantly in the 2.2.0 release.
5027# This plugin uses the Elasticsearch bulk API to optimize its imports into Elasticsearch. These requests may experience
5128# either partial or total failures.
5229#
@@ -129,8 +106,7 @@ class LogStash::Outputs::ElasticSearch < LogStash::Outputs::Base
129106 # - delete: deletes a document by id (An id is required for this action)
130107 # - create: indexes a document, fails if a document by that id already exists in the index.
131108 # - update: updates a document by id. Update has a special case where you can upsert -- update a
132- # document if not already present. See the `upsert` option. NOTE: This does not work and is not supported
133- # in Elasticsearch 1.x. Please upgrade to ES 2.x or greater to use this feature with Logstash!
109+ # document if not already present. See the `upsert` option.
134110 # - A sprintf style string to change the action based on the content of the event. The value `%{[foo]}`
135111 # would use the foo field for the action
136112 #
@@ -148,7 +124,7 @@ class LogStash::Outputs::ElasticSearch < LogStash::Outputs::Base
148124
149125 config :document_type ,
150126 :validate => :string ,
151- :deprecated => "Document types are being deprecated in Elasticsearch 6 .0, and removed entirely in 7 .0. You should avoid this feature"
127+ :deprecated => "Document types were deprecated in Elasticsearch 7 .0, and no longer configurable since 8 .0. You should avoid this feature. "
152128
153129 # From Logstash 1.3 onwards, a template is applied to Elasticsearch during
154130 # Logstash's startup if one with the name `template_name` does not already exist.
@@ -483,7 +459,7 @@ def event_action_tuple(event)
483459 join_value = event . get ( @join_field )
484460 parent_value = event . sprintf ( @parent )
485461 event . set ( @join_field , { "name" => join_value , "parent" => parent_value } )
486- params [ routing_field_name ] = event . sprintf ( @parent )
462+ params [ :routing ] = event . sprintf ( @parent )
487463 else
488464 params [ :parent ] = event . sprintf ( @parent )
489465 end
@@ -495,7 +471,7 @@ def event_action_tuple(event)
495471 if action == 'update'
496472 params [ :_upsert ] = LogStash ::Json . load ( event . sprintf ( @upsert ) ) if @upsert != ""
497473 params [ :_script ] = event . sprintf ( @script ) if @script != ""
498- params [ retry_on_conflict_action_name ] = @retry_on_conflict
474+ params [ :retry_on_conflict ] = @retry_on_conflict
499475 end
500476
501477 event_control = event . get ( "[@metadata][_ingest_document]" )
@@ -552,7 +528,7 @@ def common_event_params(event)
552528 params = {
553529 :_id => resolve_document_id ( event , event_id ) ,
554530 :_index => resolve_index! ( event , event_index ) ,
555- routing_field_name => resolve_routing ( event , event_routing )
531+ :routing => resolve_routing ( event , event_routing )
556532 }
557533
558534 target_pipeline = resolve_pipeline ( event , event_pipeline )
@@ -615,16 +591,7 @@ def resolve_pipeline(event, event_pipeline)
615591 require "logstash/outputs/elasticsearch/#{ name } "
616592 end
617593
618- def retry_on_conflict_action_name
619- maximum_seen_major_version >= 7 ? :retry_on_conflict : :_retry_on_conflict
620- end
621-
622- def routing_field_name
623- :routing
624- end
625-
626594 # Determine the correct value for the 'type' field for the given event
627- DEFAULT_EVENT_TYPE_ES6 = "doc" . freeze
628595 DEFAULT_EVENT_TYPE_ES7 = "_doc" . freeze
629596
630597 def get_event_type ( event )
@@ -633,9 +600,7 @@ def get_event_type(event)
633600 event . sprintf ( @document_type )
634601 else
635602 major_version = maximum_seen_major_version
636- if major_version == 6
637- DEFAULT_EVENT_TYPE_ES6
638- elsif major_version == 7
603+ if major_version == 7
639604 DEFAULT_EVENT_TYPE_ES7
640605 else
641606 nil
@@ -653,9 +618,9 @@ def get_event_type(event)
653618 # @param noop_required_client [nil]: required `nil` for legacy reasons.
654619 # @return [Boolean]
655620 def use_event_type? ( noop_required_client )
656- # always set type for ES 6
657- # for ES 7 only set it if the user defined it
658- ( maximum_seen_major_version < 7 ) || ( maximum_seen_major_version == 7 && @document_type )
621+ # never use event type unless
622+ # ES is 7.x and the user defined it
623+ maximum_seen_major_version == 7 && @document_type
659624 end
660625
661626 def install_template
0 commit comments