|
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]
|
@@ -316,7 +314,7 @@ def register
|
316 | 314 | @client_options = {
|
317 | 315 | :hosts => hosts,
|
318 | 316 | :transport_options => transport_options,
|
319 |
| - :transport_class => ::Elasticsearch::Transport::Transport::HTTP::Manticore, |
| 317 | + :transport_class => get_transport_client_class, |
320 | 318 | :ssl => ssl_options
|
321 | 319 | }
|
322 | 320 |
|
@@ -642,6 +640,20 @@ def setup_query_executor
|
642 | 640 | end
|
643 | 641 | end
|
644 | 642 |
|
| 643 | + def get_transport_client_class |
| 644 | + # LS-core includes `elasticsearch` gem. The gem is composed of two separate gems: `elasticsearch-api` and `elasticsearch-transport` |
| 645 | + # And now `elasticsearch-transport` is old, instead we have `elastic-transport`. |
| 646 | + # LS-core updated `elasticsearch` > 8: https://github.com/elastic/logstash/pull/17161 |
| 647 | + # Following source bits are for the compatibility to support both `elasticsearch-transport` and `elastic-transport` gems |
| 648 | + require "elasticsearch/transport/transport/http/manticore" |
| 649 | + require_relative "elasticsearch/patches/_elasticsearch_transport_http_manticore" |
| 650 | + require_relative "elasticsearch/patches/_elasticsearch_transport_connections_selector" |
| 651 | + ::Elasticsearch::Transport::Transport::HTTP::Manticore |
| 652 | + rescue ::LoadError |
| 653 | + require "elastic/transport/transport/http/manticore" |
| 654 | + ::Elastic::Transport::Transport::HTTP::Manticore |
| 655 | + end |
| 656 | + |
645 | 657 | module URIOrEmptyValidator
|
646 | 658 | ##
|
647 | 659 | # @override to provide :uri_or_empty validator
|
|
0 commit comments