|
13 | 13 | require "base64" |
14 | 14 |
|
15 | 15 | require "elasticsearch" |
16 | | -require "elasticsearch/transport/transport/http/manticore" |
17 | | -require_relative "elasticsearch/patches/_elasticsearch_transport_http_manticore" |
18 | | -require_relative "elasticsearch/patches/_elasticsearch_transport_connections_selector" |
| 16 | +require "manticore" |
19 | 17 |
|
20 | 18 | # .Compatibility Note |
21 | 19 | # [NOTE] |
@@ -323,7 +321,7 @@ def register |
323 | 321 | @client_options = { |
324 | 322 | :hosts => hosts, |
325 | 323 | :transport_options => transport_options, |
326 | | - :transport_class => ::Elasticsearch::Transport::Transport::HTTP::Manticore, |
| 324 | + :transport_class => get_transport_client_class, |
327 | 325 | :ssl => ssl_options |
328 | 326 | } |
329 | 327 |
|
@@ -678,6 +676,20 @@ def setup_query_executor |
678 | 676 | end |
679 | 677 | end |
680 | 678 |
|
| 679 | + def get_transport_client_class |
| 680 | + # LS-core includes `elasticsearch` gem. The gem is composed of two separate gems: `elasticsearch-api` and `elasticsearch-transport` |
| 681 | + # And now `elasticsearch-transport` is old, instead we have `elastic-transport`. |
| 682 | + # LS-core updated `elasticsearch` > 8: https://github.com/elastic/logstash/pull/17161 |
| 683 | + # Following source bits are for the compatibility to support both `elasticsearch-transport` and `elastic-transport` gems |
| 684 | + require "elasticsearch/transport/transport/http/manticore" |
| 685 | + require_relative "elasticsearch/patches/_elasticsearch_transport_http_manticore" |
| 686 | + require_relative "elasticsearch/patches/_elasticsearch_transport_connections_selector" |
| 687 | + ::Elasticsearch::Transport::Transport::HTTP::Manticore |
| 688 | + rescue ::LoadError |
| 689 | + require "elastic/transport/transport/http/manticore" |
| 690 | + ::Elastic::Transport::Transport::HTTP::Manticore |
| 691 | + end |
| 692 | + |
681 | 693 | module URIOrEmptyValidator |
682 | 694 | ## |
683 | 695 | # @override to provide :uri_or_empty validator |
|
0 commit comments