You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/overview.asciidoc
+6-12Lines changed: 6 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,9 +1,7 @@
1
1
[[ruby_client]]
2
2
== Overview
3
3
4
-
The `elasticsearch` http://rubygems.org/gems/elasticsearch[Rubygem] provides a
5
-
low-level client for communicating with an {es} cluster, fully compatible with
6
-
other official clients.
4
+
The `elasticsearch` http://rubygems.org/gems/elasticsearch[Rubygem] provides a low-level client for communicating with an {es} cluster, fully compatible with other official clients.
7
5
8
6
More documentation is hosted in https://github.com/elastic/elasticsearch-ruby[Github] and http://rubydoc.info/gems/elasticsearch[RubyDoc].
9
7
@@ -26,18 +24,14 @@ More documentation is hosted in https://github.com/elastic/elasticsearch-ruby[Gi
26
24
27
25
The `elasticsearch` gem combines two separate Rubygems:
Notably, the documentation and comprehensive examples for all the API methods are contained in the source, and available online at http://rubydoc.info/gems/elasticsearch-api/Elasticsearch/API/Actions[Rubydoc].
41
36
42
-
Keep in mind, that for optimal performance, you should use an HTTP library which
The `elasticsearch-transport` library provides a low-level Ruby client for
5
-
connecting to an {es} cluster.
4
+
The `elastic-transport` library provides a low-level Ruby client for connecting to an {es} cluster. It currently powers the https://www.elastic.co/guide/en/elasticsearch/client/ruby-api/current/index.html[Elasticsearch Ruby] and the https://www.elastic.co/guide/en/enterprise-search-clients/ruby/current/index.html[Enterprise Search Ruby] clients.
6
5
7
-
It handles connecting to multiple nodes in the cluster, rotating across
8
-
connections, logging and tracing requests and responses, maintaining failed
9
-
connections, discovering nodes in the cluster, and provides an abstraction for
10
-
data serialization and transport.
6
+
When available, it handles connecting to multiple nodes in the cluster, rotating across connections, logging and tracing requests and responses, maintaining failed connections, discovering nodes in the cluster, and provides an abstraction for data serialization and transport.
11
7
12
-
It does not handle calling the {es} API.
13
-
14
-
The library is compatible with Ruby 1.9 or higher and with all versions of {es}
15
-
since 0.90.
16
-
17
-
For optimal performance, use a HTTP library which supports persistent
18
-
("keep-alive") connections, such as https://github.com/toland/patron[patron] or
19
-
https://github.com/typhoeus/typhoeus[Typhoeus]. Require the library
20
-
(require 'patron') in your code, and it will be automatically used.
8
+
It does not handle calling the {es} or Enterprise Search APIs.
21
9
10
+
For optimal performance, use a HTTP library which supports persistent ("keep-alive") connections, such as https://github.com/toland/patron[patron] or https://github.com/typhoeus/typhoeus[Typhoeus]. Require the library (require 'patron') in your code, and it will be automatically used.
22
11
23
12
[discrete]
24
13
[[transport-install]]
@@ -27,21 +16,21 @@ https://github.com/typhoeus/typhoeus[Typhoeus]. Require the library
27
16
Install the package from https://rubygems.org/[Rubygems]:
28
17
29
18
```
30
-
gem install elasticsearch-transport
19
+
gem install elastic-transport
31
20
```
32
21
33
22
To use an unreleased version, either add it to your `Gemfile` for
When using the Elasticsearch or Enterprise Search clients, you can pass the `adapter` parameter when initializing the clients.
100
+
101
+
To pass options to the https://github.com/lostisland/faraday/blob/master/lib/faraday/connection.rb[`Faraday::Connection`] constructor, use the `transport_options` key:
To configure the Faraday instance directly, use a block:
128
115
129
116
```ruby
130
117
require 'patron'
131
118
132
-
client = Elasticsearch::Client.new(host: 'localhost', port: '9200') do |f|
119
+
client = Elastic::Client.new(host: 'localhost', port: '9200') do |f|
133
120
f.response :logger
134
121
f.adapter :patron
135
122
end
136
123
```
137
124
138
-
You can use any standard Faraday middleware and plugins in the configuration
139
-
block.
125
+
You can use any standard Faraday middleware and plugins in the configuration block.
140
126
141
-
You can also initialize the transport class yourself, and pass it to the client
142
-
constructor as the `transport` argument:
127
+
You can also initialize the transport class yourself, and pass it to the client constructor as the `transport` argument. The Elasticsearch and Enterprise Search clients accept `:transport` as parameter when initializing a client. So you can pass in a transport you've initialized with the following options:
143
128
144
129
```ruby
145
130
require 'patron'
@@ -149,17 +134,17 @@ transport_configuration = lambda do |f|
149
134
f.adapter :patron
150
135
end
151
136
152
-
transport = Elasticsearch::Transport::Transport::HTTP::Faraday.new \
137
+
transport = Elastic::Transport::Transport::HTTP::Faraday.new(
153
138
hosts: [ { host: 'localhost', port: '9200' } ],
154
139
&transport_configuration
140
+
)
155
141
156
142
# Pass the transport to the client
157
143
#
158
-
client = Elasticsearch::Client.newtransport: transport
You can write your own transport implementation by including the
215
-
{Elasticsearch::Transport::Transport::Base} module, implementing the required
216
-
contract, and passing it to the client as the `transport_class` parameter – or
217
-
by injecting it directly.
202
+
You can write your own transport implementation by including the {Elastic::Transport::Transport::Base} module, implementing the required contract, and passing it to the client as the `transport_class` parameter – or by injecting it directly.
218
203
219
204
[discrete]
220
205
[[transport-architecture]]
221
206
==== Transport architecture
222
207
223
-
* `Elasticsearch::Transport::Client` is composed of
224
-
`Elasticsearch::Transport::Transport`.
208
+
* `Elastic::Transport::Client` is composed of `Elastic::Transport::Transport`.
225
209
226
-
* `Elasticsearch::Transport::Transport` is composed of
227
-
`Elasticsearch::Transport::Transport::Connections`, and an instance of logger,
228
-
tracer, serializer and sniffer.
210
+
* `Elastic::Transport::Transport` is composed of `Elastic::Transport::Transport::Connections`, and an instance of logger, tracer, serializer and sniffer.
229
211
230
-
* Logger and tracer can be any object conforming to Ruby logging interface, for
https://github.com/TwP/logging/[logging], and so on.
212
+
* Logger and tracer can be any object conforming to Ruby logging interface, for example, an instance of https://ruby-doc.org/stdlib-1.9.3/libdoc/logger/rdoc/Logger.html[`Logger`], https://rubygems.org/gems/log4r[log4r], https://github.com/TwP/logging/[logging], and so on.
235
213
236
-
* The `Elasticsearch::Transport::Transport::Serializer::Base` implementations
237
-
handle converting data for {es} (for example, to JSON). You can implement your
238
-
own serializer.
214
+
* The `Elastic::Transport::Transport::Serializer::Base` implementations handle converting data for {es} (for example, to JSON). You can implement your own serializer.
239
215
240
-
* `Elasticsearch::Transport::Transport::Sniffer` allows to discover nodes in the
241
-
cluster and use them as connections.
216
+
* `Elastic::Transport::Transport::Sniffer` allows to discover nodes in the cluster and use them as connections.
242
217
243
-
* `Elasticsearch::Transport::Transport::Connections::Collection` is composed of
244
-
`Elasticsearch::Transport::Transport::Connections::Connection` instances and a
245
-
selector instance.
218
+
* `Elastic::Transport::Transport::Connections::Collection` is composed of `Elastic::Transport::Transport::Connections::Connection` instances and a selector instance.
246
219
247
-
* `Elasticsearch::Transport::Transport::Connections::Connection` contains the
248
-
connection attributes such as hostname and port, as well as the concrete
249
-
persistent "session" connected to a specific node.
220
+
* `Elastic::Transport::Transport::Connections::Connection` contains the connection attributes such as hostname and port, as well as the concrete persistent "session" connected to a specific node.
250
221
251
-
* The `Elasticsearch::Transport::Transport::Connections::Selector::Base`
252
-
implementations allow to choose connections from the pool, for example, in a
253
-
round-robin or random fashion. You can implement your own selector strategy.
222
+
* The `Elastic::Transport::Transport::Connections::Selector::Base` implementations allow to choose connections from the pool, for example, in a round-robin or random fashion. You can implement your own selector strategy.
0 commit comments